@giantswarm-io/pro 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/package.json +1 -1
- package/src/lib/auth/provider.js +22 -9
package/README.md
CHANGED
|
@@ -88,9 +88,11 @@ With `--transport=streamable-http` the server picks one of three modes:
|
|
|
88
88
|
|
|
89
89
|
In the OAuth and bearer-only modes GitHub calls run as the caller, so board
|
|
90
90
|
changes are attributed to the person. Scoped tokens (classic OAuth, classic
|
|
91
|
-
PAT) must cover `repo`, `project` and `read:org
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
PAT) must cover `repo`, `project` and `read:org` (a wider scope counts:
|
|
92
|
+
`admin:org` or `write:org` for `read:org`); GitHub App user-to-server tokens
|
|
93
|
+
and fine-grained PATs have no scopes -- GitHub reports an empty scope list for
|
|
94
|
+
them -- and are accepted as they are, GitHub enforcing their permissions on
|
|
95
|
+
each call.
|
|
94
96
|
|
|
95
97
|
### Environment Variables
|
|
96
98
|
|
package/package.json
CHANGED
package/src/lib/auth/provider.js
CHANGED
|
@@ -48,8 +48,15 @@ const AUTH_SESSION_TTL_MS = 10 * 60 * 1000;
|
|
|
48
48
|
const TOKEN_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
49
49
|
// Maximum number of registered MCP clients kept in memory
|
|
50
50
|
const MAX_CLIENTS = 1000;
|
|
51
|
-
// GitHub OAuth scopes required by PRO's tools
|
|
51
|
+
// GitHub OAuth scopes required by PRO's tools, each with the scopes that
|
|
52
|
+
// satisfy it: GitHub's classic scopes nest (admin:org > write:org > read:org),
|
|
53
|
+
// and a token announcing the wider scope has the narrower one.
|
|
52
54
|
const REQUIRED_GITHUB_SCOPES = ['repo', 'project', 'read:org'];
|
|
55
|
+
const SCOPE_SATISFIED_BY = {
|
|
56
|
+
repo: ['repo'],
|
|
57
|
+
project: ['project'],
|
|
58
|
+
'read:org': ['read:org', 'write:org', 'admin:org']
|
|
59
|
+
};
|
|
53
60
|
// GitHub's OAuth authorization server, as the hosted GitHub MCP server names it
|
|
54
61
|
// in its protected resource metadata. Used when this server runs as a plain
|
|
55
62
|
// resource server (OAUTH_BEARER_ONLY) whose tokens come from GitHub directly.
|
|
@@ -103,11 +110,13 @@ export function isCimdUrl(clientId) {
|
|
|
103
110
|
*
|
|
104
111
|
* A token is valid when GitHub's /user endpoint accepts it. Classic OAuth and
|
|
105
112
|
* PAT tokens announce their scopes in `x-oauth-scopes`; those must cover the
|
|
106
|
-
* scopes the board tools need
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
113
|
+
* scopes the board tools need (a wider scope such as `admin:org` counts for
|
|
114
|
+
* `read:org`), so a token that cannot write is refused up front. GitHub App
|
|
115
|
+
* user-to-server tokens and fine-grained PATs have no scopes -- GitHub sends
|
|
116
|
+
* the header empty or not at all; their permissions are enforced by GitHub
|
|
117
|
+
* per request -- and are accepted; a missing permission surfaces as a 403
|
|
118
|
+
* from the call that needs it. Verified tokens are cached briefly; `sweep`
|
|
119
|
+
* drops expired entries.
|
|
111
120
|
*
|
|
112
121
|
* Used by the OAuth provider (tokens this server issued) and by the
|
|
113
122
|
* bearer-only mode (tokens a client such as muster obtained from GitHub).
|
|
@@ -139,11 +148,15 @@ export function createGitHubTokenVerifier() {
|
|
|
139
148
|
}
|
|
140
149
|
|
|
141
150
|
// Scoped tokens (classic OAuth, classic PAT) announce their scopes; a
|
|
142
|
-
// token
|
|
151
|
+
// token announcing none -- header absent or empty, as for GitHub App
|
|
152
|
+
// user-to-server tokens and fine-grained PATs -- is permission-based and
|
|
153
|
+
// checked per call.
|
|
143
154
|
const scopeHeader = res.headers.get('x-oauth-scopes');
|
|
144
155
|
const grantedScopes = (scopeHeader || '').split(',').map(s => s.trim()).filter(Boolean);
|
|
145
|
-
if (
|
|
146
|
-
const missingScopes = REQUIRED_GITHUB_SCOPES.filter(
|
|
156
|
+
if (grantedScopes.length > 0) {
|
|
157
|
+
const missingScopes = REQUIRED_GITHUB_SCOPES.filter(
|
|
158
|
+
required => !SCOPE_SATISFIED_BY[required].some(scope => grantedScopes.includes(scope))
|
|
159
|
+
);
|
|
147
160
|
if (missingScopes.length > 0) {
|
|
148
161
|
throw new InsufficientScopeError(`GitHub token is missing required scopes: ${missingScopes.join(', ')}`);
|
|
149
162
|
}
|