@@ -42,17 +42,12 @@ adding the following endpoint scopes:
42
42
* ** yank** : allows yanking and unyanking existing versions of the user's crates
43
43
* ** change-owners** : allows inviting new owners or removing existing owners
44
44
* ** legacy** : allows accessing all the endpoints on crates.io except for
45
- creating new tokens, like tokens created befores the implementation of this
45
+ creating new tokens, like tokens created before the implementation of this
46
46
RFC.
47
47
48
48
More endpoint scopes might be added in the future without the need of a
49
49
dedicated RFC.
50
50
51
- The crates.io UI will pre-select the scopes needed by the ` cargo ` CLI, which at
52
- the time of writing this RFC are ` publish-new ` , ` publish-update ` , ` yank ` and
53
- ` change-owners ` . The user will have to explicitly opt into extra scopes or the
54
- legacy permission model.
55
-
56
51
Tokens created before the implementation of this RFC will default to the legacy
57
52
scope.
58
53
@@ -61,44 +56,45 @@ scope.
61
56
The user will be able to opt into limiting which crates the token can act on by
62
57
defining a crates scope.
63
58
64
- The crates scope can be left empty to allow the token to act on all the crates
65
- owned by the user, or it can contain the comma-separated list of crate names
66
- the token can interact with. Crate names can contain ` * ` to match zero or more
67
- characters.
59
+ The crates scope can contain a list of crate name patterns the token can
60
+ interact with. Crate name patterns can either be regular crate names or they
61
+ can end with a ` * ` character to match zero or more characters.
68
62
69
- For example, a crates scope of ` lazy_static,serde* ` allows the token to act on
70
- the ` lazy_static ` crate or any present or future crates starting with ` serde `
71
- (including ` serde ` itself), if the user is an owner of those crates.
63
+ For example, a crate name pattern of ` lazy_static ` will only make the token
64
+ apply to the corresponding crate, while ` serde* ` allows the token to act on
65
+ any present or future crates starting with ` serde ` (including ` serde ` itself),
66
+ but only if the user is an owner of those crates.
72
67
73
68
The crates scope will allow access to all present and future crates matching
74
69
it. When an endpoint that doesn't interact with crates is called by a token
75
70
with a crates scope, the crates scope will be ignored and the call will be
76
- authorized.
71
+ authorized, unless limited by an endpoint scope (see above) .
77
72
78
73
Tokens created before the implementation of this RFC will default to an empty
79
74
crate scope filter (equivalent to no restrictions).
80
75
81
76
# Reference-level explanation
82
77
[ reference-level-explanation ] : #reference-level-explanation
83
78
84
- Endpoint scopes and crates scope are two completly separate systems, and can be
85
- used independently from one another. Token scopes will be implemented entirely
86
- on the crates.io side, and there will be no change to ` cargo ` or alternate
87
- registries.
79
+ Endpoint scopes and crates scope are two completely separate systems, and can be
80
+ used independently of one another.
81
+
82
+ Token scopes will be implemented entirely on the crates.io side, and there will
83
+ be no change necessary to ` cargo ` or alternate registries.
88
84
89
85
## Endpoint scopes
90
86
91
87
The scopes proposed by this RFC allow access to the following endpoints:
92
88
93
- | Endpoint | Required scope |
94
- | --- | --- |
95
- | ` PUT /crates/new ` (new crates) | ** publish-new** |
96
- | ` PUT /crates/new ` (existing crates) | ** publish-update** |
97
- | ` DELETE /crates/:crate_id/:version/yank ` | ** yank** |
98
- | ` PUT /crates/:crate_id/:version/unyank ` | ** yank** |
99
- | ` PUT /crates/:crate_id/owners ` | ** change-owners** |
100
- | ` DELETE /crates/:crate_id/owners ` | ** change-owners** |
101
- | everything except ` PUT /me/tokens ` | ** legacy** |
89
+ | Endpoint | Required scope |
90
+ | ------------------------------------------ | -------------------- |
91
+ | ` PUT /crates/new ` (new crates) | ** publish-new** |
92
+ | ` PUT /crates/new ` (existing crates) | ** publish-update** |
93
+ | ` DELETE /crates/:crate_id/:version/yank ` | ** yank** |
94
+ | ` PUT /crates/:crate_id/:version/unyank ` | ** yank** |
95
+ | ` PUT /crates/:crate_id/owners ` | ** change-owners** |
96
+ | ` DELETE /crates/:crate_id/owners ` | ** change-owners** |
97
+ | everything except ` PUT /me/tokens ` | ** legacy** |
102
98
103
99
Removing an endpoint from a scope or adding an existing endpoint to an existing
104
100
scope will be considered a breaking change. Adding newly created endpoints to
@@ -108,31 +104,7 @@ existing set of endpoints in that scope.
108
104
109
105
## Crates scope
110
106
111
- The pattern for the crate scope is desugared into a regular expression,
112
- following these rules:
113
-
114
- * ** ` ^( ` ** is added at the start of the pattern, and ** ` )$ ` ** is added at the end of it.
115
- * ** ` , ` ** is desugared into ` | ` , separating multiple patterns.
116
- * ** ` * ` ** is desugared into ` .* ` , matching zero or more characters greedily.
117
- * All other non-alphanumeric characters are quoted to prevent them from having
118
- a special meaning.
119
-
120
- As an example, the following pattern:
121
-
122
- ```
123
- foo,bar-*
124
- ```
125
-
126
- ... is desugared into the following regex:
127
-
128
- ```
129
- ^(foo|bar\-.*)$
130
- ```
131
-
132
- Any combination of those characters is allowed, but crates.io might define a
133
- complexity limit for the generated regular expressions.
134
-
135
- The pattern will be evaluated during each API call, and if no match is found
107
+ The patterns will be evaluated during each API call, and if no match is found
136
108
the request will be denied. Because it's evaluated every time, a crates scope
137
109
will allow interacting with matching crates published after token creation.
138
110
@@ -162,7 +134,7 @@ in the RFC author's opinion, are more likely to need crate scopes than a person
162
134
with just a few crates), and it wouldn't allow new crates matching the pattern
163
135
but uploaded after the token's creation from being accessed.
164
136
165
- Finally an alternative could be to do nothing, and encourage users to create
137
+ Finally, an alternative could be to do nothing, and encourage users to create
166
138
"machine accounts" for each set of crates they own. A drawback of this is that
167
139
GitHub's terms of service limit how many accounts a single person could have.
168
140
@@ -222,7 +194,7 @@ implementation of solutions that would make the check hard.
222
194
To increase the security of CI environments even more, we could implement an
223
195
option to require a separate confirmation for the actions executed by tokens.
224
196
For example, we could send a confirmation email with a link the owners have to
225
- click to actually publish the crate uploaded by CI, preventing any mailicious
197
+ click to actually publish the crate uploaded by CI, preventing any malicious
226
198
action with stolen tokens.
227
199
228
200
To remove the need for machine accounts, a future RFC could propose adding API
0 commit comments