Skip to content

Commit ef592cf

Browse files
authored
Merge pull request #371 from brendandburns/oidc
Don't require client-secret in OIDC authentication.
2 parents 36c9095 + ca55c20 commit ef592cf

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/oidc_auth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ export class OpenIDConnectAuth implements Authenticator {
3333
}
3434

3535
private async getToken(user: User, overrideClient?: Client): Promise<string | null> {
36+
if (!user.authProvider.config) {
37+
return null;
38+
}
39+
if (!user.authProvider.config['client-secret']) {
40+
user.authProvider.config['client-secret'] = '';
41+
}
3642
if (
3743
!user.authProvider.config ||
3844
!user.authProvider.config['id-token'] ||
3945
!user.authProvider.config['client-id'] ||
40-
!user.authProvider.config['client-secret'] ||
4146
!user.authProvider.config['refresh-token'] ||
4247
!user.authProvider.config['idp-issuer-url']
4348
) {

src/oidc_auth_test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('OIDCAuth', () => {
7070
expect(opts.headers.Authorization).to.be.undefined;
7171
});
7272

73-
it('authorization should be undefined if client-secret missing', async () => {
73+
it('authorization should be work if client-secret missing', async () => {
7474
const user = {
7575
authProvider: {
7676
name: 'oidc',
@@ -85,8 +85,9 @@ describe('OIDCAuth', () => {
8585

8686
const opts = {} as request.Options;
8787
opts.headers = [];
88-
await auth.applyAuthentication(user, opts);
89-
expect(opts.headers.Authorization).to.be.undefined;
88+
(auth as any).currentTokenExpiration = Date.now() / 1000 + 1000;
89+
await auth.applyAuthentication(user, opts, {});
90+
expect(opts.headers.Authorization).to.equal('Bearer fakeToken');
9091
});
9192

9293
it('authorization should be undefined if refresh-token missing', async () => {

0 commit comments

Comments
 (0)