@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 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`; GitHub App user-to-server
92
- tokens and fine-grained PATs carry no scope list and are accepted as they
93
- are, GitHub enforcing their permissions on each call.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giantswarm-io/pro",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "Core library and MCP server for managing Giant Swarm's roadmap and customer project boards",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -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, so a token that cannot write is refused up
107
- * front. GitHub App user-to-server tokens and fine-grained PATs carry no such
108
- * header -- their permissions are enforced by GitHub per request -- and are
109
- * accepted; a missing permission surfaces as a 403 from the call that needs
110
- * it. Verified tokens are cached briefly; `sweep` drops expired entries.
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 without the header is permission-based and checked per call.
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 (scopeHeader !== null && scopeHeader !== undefined) {
146
- const missingScopes = REQUIRED_GITHUB_SCOPES.filter(s => !grantedScopes.includes(s));
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
  }