Skip to content

Commit

Permalink
fix for github auth
Browse files Browse the repository at this point in the history
  • Loading branch information
lelemm committed Dec 19, 2024
1 parent c468d0f commit 2ec5b1c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/accounts/openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,22 @@ export async function loginWithOpenIdFinalize(body) {
let { code_verifier, return_url } = pendingRequest;

try {
const params = { code: body.code, state: body.state };
let tokenSet = await client.callback(client.redirect_uris[0], params, {
code_verifier,
state: body.state,
});
let tokenSet = null;

if (!config.authMethod || config.authMethod === 'openid') {
const params = { code: body.code, state: body.state };
tokenSet = await client.callback(client.redirect_uris[0], params, {
code_verifier,
state: body.state,
});
} else {
tokenSet = await client.grant({
grant_type: 'authorization_code',
code: body.code,
redirect_uri: client.redirect_uris[0],
code_verifier,
});
}
const userInfo = await client.userinfo(tokenSet.access_token);
const identity =
userInfo.preferred_username ??
Expand Down
1 change: 1 addition & 0 deletions src/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface Config {
client_id: string;
client_secret: string;
server_hostname: string;
authMethod?: 'openid' | 'oauth2';
};
multiuser: boolean;
token_expiration?: 'never' | 'openid-provider' | number;
Expand Down
2 changes: 1 addition & 1 deletion upcoming-release-notes/527.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ category: Enhancements
authors: [lelemm]
---

Commands to enable/disable OpenID from console.
Commands to enable/disable OpenID from console. Also, enabling to login with oauth2 (for github).

0 comments on commit 2ec5b1c

Please sign in to comment.