feat: oauth role claim (#19758)

This commit is contained in:
Daniel Dietzler 2025-07-07 00:45:32 +02:00 committed by GitHub
parent 2f5d75ce21
commit 4ce9bce414
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 160 additions and 3 deletions

View file

@ -227,6 +227,21 @@ describe(`/oauth`, () => {
expect(user.storageLabel).toBe('user-username');
});
it('should set the admin status from a role claim', async () => {
const callbackParams = await loginWithOAuth(OAuthUser.WITH_ROLE);
const { status, body } = await request(app).post('/oauth/callback').send(callbackParams);
expect(status).toBe(201);
expect(body).toMatchObject({
accessToken: expect.any(String),
userId: expect.any(String),
userEmail: 'oauth-with-role@immich.app',
isAdmin: true,
});
const user = await getMyUser({ headers: asBearerAuth(body.accessToken) });
expect(user.isAdmin).toBe(true);
});
it('should work with RS256 signed tokens', async () => {
await setupOAuth(admin.accessToken, {
enabled: true,