You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 012e654
Browse filesBrowse the repository at this point in the historyBrowse files
feat: require a PKCE-style code challenge and verifier for ORCID sign-up
GetOrcidSignUpAuthorizationUrl now takes a codeChallenge (base64url SHA-256
of a random code verifier), and ConnectOrcidForSignUp sends the matching
codeVerifier, as required by IQSS/dataverse#12858.
Returns the ORCID authorization URL that sends a new user to ORCID to authenticate their ORCID iD while signing up. Send the user's browser to this URL; after they sign in, ORCID redirects back to `redirectUri` with `code` and `state` query parameters, which are then passed to [Connect ORCID For Sign-Up](#connect-orcid-for-sign-up).
2794
2794
2795
-
No credentials are sent, so this works for anonymous users. The installation needs an ORCID OAuth2 provider (it can be disabled for login), and `redirectUri` must be listed in its `dataverse.api.signup.orcid-redirect-uris` setting.
2795
+
No credentials are sent, so this works for anonymous users. The installation needs an ORCID OAuth2 provider (it can be disabled for login), and `redirectUri` must be allowed by the installation: by default, its site URL followed by `/modern/sign-up`, or a URL listed in its `dataverse.api.signup.orcid-redirect-uris` setting.
2796
+
2797
+
As with PKCE, create a random code verifier first and keep it (for example in `sessionStorage`). Pass its base64url-encoded SHA-256 hash as `codeChallenge`, and the verifier itself to [Connect ORCID For Sign-Up](#connect-orcid-for-sign-up). An ORCID response can then only be used by the browser that started the flow.
2796
2798
2797
2799
##### Example call:
2798
2800
@@ -2801,18 +2803,32 @@ import { getOrcidSignUpAuthorizationUrl } from '@iqss/dataverse-client-javascrip
The use case throws a `ReadError` with `statusCode` 404 when no ORCID provider is configured, and 400 when the redirect URI is not allowed.
2831
+
The use case throws a `ReadError` with `statusCode` 404 when no ORCID provider is configured, and 400 when the redirect URI is not allowed or the code challenge is missing or invalid.
2816
2832
2817
2833
### Users write use cases
2818
2834
@@ -2927,7 +2943,7 @@ The [SignUpResult](../src/users/domain/models/SignUpResult.ts) is `{ status: 'cr
2927
2943
2928
2944
### Connect ORCID For Sign-Up
2929
2945
2930
-
Exchanges the `code` and `state` that ORCID returns to the redirect URI for the user's authenticated ORCID iD, given an [OrcidSignUpCallbackDTO](../src/users/domain/dtos/OrcidSignUpCallbackDTO.ts). Use the same `redirectUri` that was passed to [Get ORCID Sign-Up Authorization URL](#get-orcid-sign-up-authorization-url). No credentials are sent.
2946
+
Exchanges the `code` and `state` that ORCID returns to the redirect URI for the user's authenticated ORCID iD, given an [OrcidSignUpCallbackDTO](../src/users/domain/dtos/OrcidSignUpCallbackDTO.ts). Use the same `redirectUri` that was passed to [Get ORCID Sign-Up Authorization URL](#get-orcid-sign-up-authorization-url), and the `codeVerifier` whose hash was passed there as `codeChallenge`. No credentials are sent.
2931
2947
2932
2948
Returns an [OrcidSignUpConnection](../src/users/domain/models/OrcidSignUpConnection.ts) with the ORCID iD, any details the user shares on their ORCID record (useful to pre-fill a sign-up form), and an `orcidToken` to include in [Sign Up](#sign-up). The token is valid for 30 minutes.
The use case throws a `WriteError` with `statusCode` 409 when the ORCID iD is already linked to another account, and 400 when the state is invalid or expired.
2975
+
The use case throws a `WriteError` with `statusCode` 409 when the ORCID iD is already linked to another account, and 400 when the state is invalid or expired, or the code verifier doesn't match the code challenge.
Copy file name to clipboardExpand all lines: src/users/domain/useCases/GetOrcidSignUpAuthorizationUrl.ts
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,11 @@ export class GetOrcidSignUpAuthorizationUrl implements UseCase<string> {
13
13
* No authentication is used.
14
14
*
15
15
* @param {string} [redirectUri] - The URL ORCID redirects back to. Must be allowed by the installation's dataverse.api.signup.orcid-redirect-uris setting.
16
+
* @param {string} [codeChallenge] - The base64url-encoded SHA-256 hash of a random code verifier that the client keeps and later passes to connectOrcidForSignUp, as for PKCE S256.
16
17
* @returns {Promise<string>} - The ORCID authorization URL.
17
-
* @throws {ReadError} - If ORCID is not configured, or the redirect URI is not allowed.
18
+
* @throws {ReadError} - If ORCID is not configured, or the redirect URI or code challenge is not valid.
0 commit comments