Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support x_authentication_flow_group in authz request #284

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support x_authentication_flow_group in web sdk
IniZio committed Apr 19, 2024

Unverified

This user has not yet uploaded their public signing key.
commit ec9978251a0c520035d03e0af78ee8d6775ada3a
31 changes: 29 additions & 2 deletions example/reactweb/src/App.tsx
Original file line number Diff line number Diff line change
@@ -90,6 +90,8 @@ function Root() {
const [clientID, setClientID] = useState(initialClientID);
const [endpoint, setEndpoint] = useState(initialEndpoint);
const [isSSOEnabled, setIsSSOEnabled] = useState(initialIsSSOEnabled);
const [page, setPage] = useState<string>();
const [authenticationFlowGroup, setAuthenticationflowGroup] = useState<string>("");

const [error, setError] = useState<unknown>(null);
const [userInfo, setUserInfo] = useState<UserInfo | null>(null);
@@ -213,12 +215,14 @@ function Root() {
.startAuthentication({
redirectURI: makeRedirectURI(),
state: "authenticate",
page,
authenticationFlowGroup,
})
.then(
() => {},
(err) => setError(err)
);
}, []);
}, [page, authenticationFlowGroup]);

const onClickSignInAnonymously = useCallback(
(e: React.MouseEvent<HTMLElement>) => {
@@ -284,6 +288,7 @@ function Root() {
.startReauthentication({
redirectURI: makeRedirectURI(),
state: "reauthenticate",
authenticationFlowGroup,
})
.then(
() => {},
@@ -300,7 +305,7 @@ function Root() {
(err) => setError(err)
);
},
[]
[authenticationFlowGroup]
);

const onClickPromoteAnonymousUser = useCallback(
@@ -382,6 +387,28 @@ function Root() {
onChange={onChangeEndpoint}
/>
</label>
<label className="label">
Authentication Flow Group
<input
className="input"
type="text"
placeholder="Enter Flow Group"
value={authenticationFlowGroup}
onChange={(e) => setAuthenticationflowGroup(e.currentTarget.value)}
/>
</label>
<label className="label">
Page
<select
className="input"
value={page}
onChange={(e) => setPage(e.currentTarget.value)}
>
<option value={undefined}>Unset</option>
<option value="signup">Signup</option>
<option value="login">Login</option>
</select>
</label>
<label className="label">
Is SSO Enabled
<input
3 changes: 3 additions & 0 deletions packages/authgear-core/src/container.ts
Original file line number Diff line number Diff line change
@@ -416,6 +416,9 @@ export class _BaseContainer<T extends _BaseAPIClient> {
query.append("x_suppress_idp_session_cookie", "true");
}
query.append("x_sso_enabled", this.isSSOEnabled ? "true" : "false");
if (options.authenticationFlowGroup != null) {
query.append("x_authentication_flow_group", options.authenticationFlowGroup);
}

return `${config.authorization_endpoint}?${query.toString()}`;
}
1 change: 1 addition & 0 deletions packages/authgear-core/src/types.ts
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@ export interface _OIDCAuthenticationRequest {
suppressIDPSessionCookie?: boolean;
oauthProviderAlias?: string;
xSettingsAction?: "change_password";
authenticationFlowGroup?: string;
}

/**
8 changes: 8 additions & 0 deletions packages/authgear-web/src/types.ts
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ export interface ReauthenticateOptions {
* OIDC max_age
*/
maxAge?: number;
/**
* Authentication flow group
*/
authenticationFlowGroup?: string;
}

/**
@@ -117,6 +121,10 @@ export interface AuthenticateOptions {
* then set oauthProviderAlias to "google".
*/
oauthProviderAlias?: string;
/**
* Authentication flow group
*/
authenticationFlowGroup?: string;
}

/**