zudoku 0.3.0-dev.69 → 0.3.0-dev.70
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/dist/config/config.d.ts +14 -12
- package/dist/lib/authentication/Callback.d.ts +1 -1
- package/dist/lib/authentication/Callback.js +2 -2
- package/dist/lib/authentication/Callback.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +2 -3
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +5 -5
- package/dist/lib/authentication/providers/openid.js +13 -1
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/lib/zudoku.auth-auth0.js +9 -10
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-openid.js +55 -55
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/authentication/Callback.tsx +3 -3
- package/src/lib/authentication/providers/auth0.tsx +2 -3
- package/src/lib/authentication/providers/openid.tsx +17 -6
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { OAuthAuthorizationError } from "./errors.js";
|
|
|
5
5
|
export function Callback({
|
|
6
6
|
handleCallback,
|
|
7
7
|
}: {
|
|
8
|
-
handleCallback: () => Promise<
|
|
8
|
+
handleCallback: () => Promise<string>;
|
|
9
9
|
}) {
|
|
10
10
|
const didInitialize = useRef(false);
|
|
11
11
|
const [error, setError] = useState<Error | undefined>(undefined);
|
|
@@ -20,9 +20,9 @@ export function Callback({
|
|
|
20
20
|
}
|
|
21
21
|
didInitialize.current = true;
|
|
22
22
|
handleCallback()
|
|
23
|
-
.then(() => {
|
|
23
|
+
.then((redirect) => {
|
|
24
24
|
// TODO: Handle return url, state, etc
|
|
25
|
-
navigate(
|
|
25
|
+
navigate(redirect);
|
|
26
26
|
})
|
|
27
27
|
.catch((err) => {
|
|
28
28
|
setError(err);
|
|
@@ -44,12 +44,11 @@ class Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {
|
|
|
44
44
|
|
|
45
45
|
const auth0Auth: AuthenticationProviderInitializer<
|
|
46
46
|
Auth0AuthenticationConfig
|
|
47
|
-
> = ({ domain,
|
|
47
|
+
> = ({ domain, ...options }) =>
|
|
48
48
|
new Auth0AuthenticationProvider({
|
|
49
|
+
...options,
|
|
49
50
|
type: "openid",
|
|
50
51
|
issuer: `https://${domain}`,
|
|
51
|
-
clientId: clientId,
|
|
52
|
-
audience: audience,
|
|
53
52
|
});
|
|
54
53
|
|
|
55
54
|
export default auth0Auth;
|
|
@@ -22,7 +22,7 @@ interface TokenState {
|
|
|
22
22
|
class OpenIdAuthPlugin extends AuthenticationPlugin {
|
|
23
23
|
constructor(
|
|
24
24
|
private callbackUrlPath: string,
|
|
25
|
-
private handleCallback: () => Promise<
|
|
25
|
+
private handleCallback: () => Promise<string>,
|
|
26
26
|
) {
|
|
27
27
|
super();
|
|
28
28
|
}
|
|
@@ -48,9 +48,9 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
48
48
|
|
|
49
49
|
protected callbackUrlPath = "/oauth/callback";
|
|
50
50
|
protected logoutRedirectUrlPath = "/";
|
|
51
|
-
private redirectToAfterSignUp
|
|
52
|
-
private redirectToAfterSignIn
|
|
53
|
-
private redirectToAfterSignOut
|
|
51
|
+
private redirectToAfterSignUp: string;
|
|
52
|
+
private redirectToAfterSignIn: string;
|
|
53
|
+
private redirectToAfterSignOut: string;
|
|
54
54
|
|
|
55
55
|
constructor({
|
|
56
56
|
issuer,
|
|
@@ -129,6 +129,11 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
129
129
|
private async authorize(signUp = false): Promise<void> {
|
|
130
130
|
const code_challenge_method = "S256";
|
|
131
131
|
const authorizationServer = await this.getAuthServer();
|
|
132
|
+
if (signUp) {
|
|
133
|
+
localStorage.setItem("sign-up", "true");
|
|
134
|
+
} else {
|
|
135
|
+
localStorage.removeItem("sign-up");
|
|
136
|
+
}
|
|
132
137
|
|
|
133
138
|
if (!authorizationServer.authorization_endpoint) {
|
|
134
139
|
throw new AuthorizationError("No authorization endpoint");
|
|
@@ -250,7 +255,7 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
250
255
|
}
|
|
251
256
|
}
|
|
252
257
|
|
|
253
|
-
handleCallback = async (): Promise<
|
|
258
|
+
handleCallback = async (): Promise<string> => {
|
|
254
259
|
const url = new URL(window.location.href);
|
|
255
260
|
const state = url.searchParams.get("state");
|
|
256
261
|
|
|
@@ -282,7 +287,7 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
282
287
|
}
|
|
283
288
|
|
|
284
289
|
const redirectUrl = new URL(url);
|
|
285
|
-
redirectUrl.pathname = this.callbackUrlPath;
|
|
290
|
+
redirectUrl.pathname = this.redirectToAfterSignIn ?? this.callbackUrlPath;
|
|
286
291
|
redirectUrl.search = "";
|
|
287
292
|
|
|
288
293
|
const response = await oauth.authorizationCodeGrantRequest(
|
|
@@ -332,6 +337,12 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
332
337
|
profile,
|
|
333
338
|
});
|
|
334
339
|
|
|
340
|
+
if (localStorage.getItem("sign-up")) {
|
|
341
|
+
return this.redirectToAfterSignUp;
|
|
342
|
+
} else {
|
|
343
|
+
return this.redirectToAfterSignIn;
|
|
344
|
+
}
|
|
345
|
+
|
|
335
346
|
// // Remove the query strings so react query doesn't keep retrying
|
|
336
347
|
// // to make the token request
|
|
337
348
|
// history.replaceState({}, "", window.location.pathname);
|