chore: cleanup a little bit more 🎉
Signed-off-by: benjdlambert <ben@blam.sh> Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
@@ -281,28 +281,6 @@ describe('migrations', () => {
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(
|
||||
knex
|
||||
.insert({
|
||||
id: 'invalid-session',
|
||||
client_id: 'non-existent-client',
|
||||
redirect_uri: 'https://example.com/callback',
|
||||
response_type: 'code',
|
||||
expires_at: new Date(),
|
||||
})
|
||||
.into('oauth_authorization_sessions'),
|
||||
).rejects.toThrow();
|
||||
|
||||
await expect(
|
||||
knex
|
||||
.insert({
|
||||
code: 'invalid-code',
|
||||
session_id: 'non-existent-session',
|
||||
expires_at: new Date(),
|
||||
})
|
||||
.into('oidc_authorization_codes'),
|
||||
).rejects.toThrow();
|
||||
|
||||
await knex('oauth_authorization_sessions')
|
||||
.where('id', 'test-session-id')
|
||||
.del();
|
||||
|
||||
@@ -244,16 +244,16 @@ describe('OidcService', () => {
|
||||
mocks: { config },
|
||||
} = await createOidcService(databaseId);
|
||||
|
||||
config.getOptionalStringArray.mockReturnValue(['cursor://*']);
|
||||
config.getOptionalStringArray.mockReturnValue(['cursor:*']);
|
||||
|
||||
const client = await service.registerClient({
|
||||
clientName: 'Test Client',
|
||||
redirectUris: ['cursor://callback'],
|
||||
redirectUris: ['cursor://callback/asd?asd=asd'],
|
||||
});
|
||||
|
||||
expect(client).toEqual(
|
||||
expect.objectContaining({
|
||||
redirectUris: ['cursor://callback'],
|
||||
redirectUris: ['cursor://callback/asd?asd=asd'],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -25,6 +25,7 @@ import { decodeJwt } from 'jose';
|
||||
import crypto from 'crypto';
|
||||
import { OidcDatabase } from '../database/OidcDatabase';
|
||||
import { DateTime } from 'luxon';
|
||||
import matcher from 'matcher';
|
||||
|
||||
export class OidcService {
|
||||
private constructor(
|
||||
@@ -121,17 +122,15 @@ export class OidcService {
|
||||
|
||||
const allowedRedirectUriPatterns = this.config.getOptionalStringArray(
|
||||
'auth.experimentalDynamicClientRegistration.allowedRedirectUriPatterns',
|
||||
);
|
||||
) ?? ['*'];
|
||||
|
||||
if (allowedRedirectUriPatterns) {
|
||||
for (const redirectUri of opts.redirectUris ?? []) {
|
||||
if (
|
||||
!allowedRedirectUriPatterns.some(pattern =>
|
||||
new RegExp(pattern).test(redirectUri),
|
||||
)
|
||||
) {
|
||||
throw new InputError('Invalid redirect_uri');
|
||||
}
|
||||
for (const redirectUri of opts.redirectUris ?? []) {
|
||||
if (
|
||||
!allowedRedirectUriPatterns.some(pattern =>
|
||||
matcher.isMatch(redirectUri, pattern),
|
||||
)
|
||||
) {
|
||||
throw new InputError('Invalid redirect_uri');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user