@cloudflare/workers-oauth-provider 0.10.2 → 0.10.3
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 +2 -0
- package/dist/oauth-provider.d.ts +14 -0
- package/dist/oauth-provider.js +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -248,6 +248,8 @@ A typical flow has three steps:
|
|
|
248
248
|
|
|
249
249
|
`completeAuthorization()` stores a new grant and, by default, revokes existing grants for the same user and client after the new grant is safely stored. Set `revokeExistingGrants: false` only when the application intentionally allows concurrent grants for the same user and client.
|
|
250
250
|
|
|
251
|
+
For Client ID Metadata Document clients, whose client_id is the metadata URL shared by every installation, default revocation is additionally scoped to grants created from the same redirect URI, so one installation's re-authorization does not revoke another's. Grants created before the redirect URI was recorded are never auto-revoked by CIMD clients.
|
|
252
|
+
|
|
251
253
|
For users with many grants, `revokeExistingGrantsBatchSize` controls the KV page size used during that scan. It defaults to `50` and is capped at KV's maximum page size of `1000`.
|
|
252
254
|
|
|
253
255
|
### Authorization response issuer
|
package/dist/oauth-provider.d.ts
CHANGED
|
@@ -1103,6 +1103,13 @@ interface Grant {
|
|
|
1103
1103
|
* Indicates the protected resource(s) for which access is requested
|
|
1104
1104
|
*/
|
|
1105
1105
|
resource?: string | string[];
|
|
1106
|
+
/**
|
|
1107
|
+
* The exact redirect URI used in the authorization request that created this grant
|
|
1108
|
+
* Recorded so that default grant revocation can be scoped to a single installation
|
|
1109
|
+
* of a CIMD client (whose client_id is shared across all installations). Absent on
|
|
1110
|
+
* grants created before this field was introduced.
|
|
1111
|
+
*/
|
|
1112
|
+
redirectUri?: string;
|
|
1106
1113
|
}
|
|
1107
1114
|
/**
|
|
1108
1115
|
* OAuth 2.0 Token Response
|
|
@@ -1314,6 +1321,13 @@ interface GrantSummary {
|
|
|
1314
1321
|
* Unix timestamp when the grant expires (if TTL is configured)
|
|
1315
1322
|
*/
|
|
1316
1323
|
expiresAt?: number;
|
|
1324
|
+
/**
|
|
1325
|
+
* The exact redirect URI used in the authorization request that created this grant
|
|
1326
|
+
* Recorded so that default grant revocation can be scoped to a single installation
|
|
1327
|
+
* of a CIMD client (whose client_id is shared across all installations). Absent on
|
|
1328
|
+
* grants created before this field was introduced.
|
|
1329
|
+
*/
|
|
1330
|
+
redirectUri?: string;
|
|
1317
1331
|
}
|
|
1318
1332
|
/**
|
|
1319
1333
|
* OAuth 2.0 Provider implementation for Cloudflare Workers
|
package/dist/oauth-provider.js
CHANGED
|
@@ -3572,6 +3572,7 @@ var OAuthHelpersImpl = class {
|
|
|
3572
3572
|
validateAuthorizationPkce(this.provider.serverCapabilities, options.request, clientInfo);
|
|
3573
3573
|
let grantsToRevoke = [];
|
|
3574
3574
|
if (options.revokeExistingGrants !== false) {
|
|
3575
|
+
const isCimdClient = this.provider.isClientMetadataUrl(clientId);
|
|
3575
3576
|
const batchSize = getRevokeExistingGrantsBatchSize(options.revokeExistingGrantsBatchSize);
|
|
3576
3577
|
let cursor;
|
|
3577
3578
|
do {
|
|
@@ -3579,7 +3580,7 @@ var OAuthHelpersImpl = class {
|
|
|
3579
3580
|
cursor,
|
|
3580
3581
|
limit: batchSize
|
|
3581
3582
|
});
|
|
3582
|
-
for (const grant of page.items) if (grant.clientId === clientId) grantsToRevoke.push(grant.id);
|
|
3583
|
+
for (const grant of page.items) if (grant.clientId === clientId && (!isCimdClient || grant.redirectUri === options.request.redirectUri)) grantsToRevoke.push(grant.id);
|
|
3583
3584
|
cursor = page.cursor;
|
|
3584
3585
|
} while (cursor);
|
|
3585
3586
|
}
|
|
@@ -3603,7 +3604,8 @@ var OAuthHelpersImpl = class {
|
|
|
3603
3604
|
metadata: options.metadata,
|
|
3604
3605
|
encryptedProps: encryptedData,
|
|
3605
3606
|
createdAt: now,
|
|
3606
|
-
resource: effectiveResource
|
|
3607
|
+
resource: effectiveResource,
|
|
3608
|
+
redirectUri: options.request.redirectUri
|
|
3607
3609
|
};
|
|
3608
3610
|
const grantKey = `grant:${options.userId}:${grantId}`;
|
|
3609
3611
|
await this.env.OAUTH_KV.put(grantKey, JSON.stringify(grant));
|
|
@@ -3653,7 +3655,8 @@ var OAuthHelpersImpl = class {
|
|
|
3653
3655
|
authCodeWrappedKey,
|
|
3654
3656
|
codeChallenge: options.request.codeChallenge,
|
|
3655
3657
|
codeChallengeMethod: options.request.codeChallengeMethod,
|
|
3656
|
-
resource: effectiveResource
|
|
3658
|
+
resource: effectiveResource,
|
|
3659
|
+
redirectUri: options.request.redirectUri
|
|
3657
3660
|
};
|
|
3658
3661
|
const grantKey = `grant:${options.userId}:${grantId}`;
|
|
3659
3662
|
await this.env.OAUTH_KV.put(grantKey, JSON.stringify(grant), { expirationTtl: 600 });
|
|
@@ -3810,7 +3813,8 @@ var OAuthHelpersImpl = class {
|
|
|
3810
3813
|
scope: grantData.scope,
|
|
3811
3814
|
metadata: grantData.metadata,
|
|
3812
3815
|
createdAt: grantData.createdAt,
|
|
3813
|
-
expiresAt: grantData.expiresAt
|
|
3816
|
+
expiresAt: grantData.expiresAt,
|
|
3817
|
+
redirectUri: grantData.redirectUri
|
|
3814
3818
|
};
|
|
3815
3819
|
grantSummaries.push(summary);
|
|
3816
3820
|
}
|