mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
feat(core): generate oidc metadata for protected app (#5188)
This commit is contained in:
parent
7d35afd30d
commit
0b08da2b46
3 changed files with 16 additions and 3 deletions
|
@ -110,6 +110,10 @@ describe('application route', () => {
|
|||
name,
|
||||
type,
|
||||
protectedAppMetadata,
|
||||
oidcClientMetadata: {
|
||||
redirectUris: [`https://${protectedAppMetadata?.host ?? ''}/callback`],
|
||||
postLogoutRedirectUris: [`https://${protectedAppMetadata?.host ?? ''}`],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import {
|
|||
applicationCreateGuard,
|
||||
applicationPatchGuard,
|
||||
} from './types.js';
|
||||
import { buildProtectedAppMetadata } from './utils.js';
|
||||
import { buildProtectedAppData } from './utils.js';
|
||||
|
||||
const includesInternalAdminRole = (roles: Readonly<Array<{ role: Role }>>) =>
|
||||
roles.some(({ role: { name } }) => name === InternalRole.Admin);
|
||||
|
@ -161,7 +161,7 @@ export default function applicationRoutes<T extends AuthedRouter>(
|
|||
...conditional(
|
||||
rest.type === ApplicationType.Protected &&
|
||||
protectedAppMetadata &&
|
||||
buildProtectedAppMetadata(protectedAppMetadata)
|
||||
buildProtectedAppData(protectedAppMetadata)
|
||||
),
|
||||
...rest,
|
||||
});
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
import { defaultProtectedAppPageRules, defaultProtectedAppSessionDuration } from './constants.js';
|
||||
|
||||
export const buildProtectedAppMetadata = ({ host, origin }: { host: string; origin: string }) => ({
|
||||
/**
|
||||
* Build application data for protected app
|
||||
* generate default protectedAppMetadata based on host and origin
|
||||
* generate redirectUris and postLogoutRedirectUris based on host
|
||||
*/
|
||||
export const buildProtectedAppData = ({ host, origin }: { host: string; origin: string }) => ({
|
||||
protectedAppMetadata: {
|
||||
host,
|
||||
origin,
|
||||
sessionDuration: defaultProtectedAppSessionDuration,
|
||||
pageRules: defaultProtectedAppPageRules,
|
||||
},
|
||||
oidcClientMetadata: {
|
||||
redirectUris: [`https://${host}/callback`],
|
||||
postLogoutRedirectUris: [`https://${host}`],
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue