Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth-admin): Allow non super users to publish super user fields #17290

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -431,23 +431,26 @@ describe('MeClientsController with auth', () => {
slidingRefreshTokenLifetime:
typeSpecificDefaults.slidingRefreshTokenLifetime ??
clientBaseAttributes.slidingRefreshTokenLifetime,
accessTokenLifetime: clientBaseAttributes.accessTokenLifetime,
accessTokenLifetime:
typeSpecificDefaults.accessTokenLifetime ??
clientBaseAttributes.accessTokenLifetime,
allowOfflineAccess: clientBaseAttributes.allowOfflineAccess,
redirectUris: [],
postLogoutRedirectUris: [],
requireApiScopes: false,
requireConsent: false,
requirePkce: true,
supportTokenExchange: false,
requirePkce:
typeSpecificDefaults.requirePkce ?? clientBaseAttributes.requirePkce,
supportTokenExchange: typeSpecificDefaults.supportTokenExchange,
supportsCustomDelegation: false,
supportsLegalGuardians: false,
supportsPersonalRepresentatives: false,
supportsProcuringHolders: false,
promptDelegations: false,
customClaims: [],
customClaims: typeSpecificDefaults.customClaims ?? [],
singleSession: false,
supportedDelegationTypes: [],
allowedAcr: [defaultAcrValue],
allowedAcr: typeSpecificDefaults.allowedAcr ?? [defaultAcrValue],
})

// Assert - db record
Expand All @@ -468,9 +471,14 @@ describe('MeClientsController with auth', () => {
absoluteRefreshTokenLifetime:
typeSpecificDefaults.absoluteRefreshTokenLifetime ??
clientBaseAttributes.absoluteRefreshTokenLifetime,
accessTokenLifetime: clientBaseAttributes.accessTokenLifetime,
allowOfflineAccess: clientBaseAttributes.allowOfflineAccess,
requirePkce: clientBaseAttributes.requirePkce,
accessTokenLifetime:
typeSpecificDefaults.accessTokenLifetime ??
clientBaseAttributes.accessTokenLifetime,
allowOfflineAccess:
typeSpecificDefaults.allowOfflineAccess ??
clientBaseAttributes.allowOfflineAccess,
requirePkce:
typeSpecificDefaults.requirePkce ?? clientBaseAttributes.requirePkce,
refreshTokenExpiration: translateRefreshTokenExpiration(
typeSpecificDefaults.refreshTokenExpiration,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,6 @@ export class AdminClientsService {
throw new BadRequestException('Invalid client id')
}

// If user is not super admin, we remove the super admin fields from the input to default to the client base attributes
if (!this.isSuperAdmin(user)) {
clientDto = {
clientId: clientDto.clientId,
clientType: clientDto.clientType,
clientName: clientDto.clientName,
// Remove defined super admin fields
...omit(clientDto, superUserFields),
// Remove personal representative from delegation types since it is not allowed for non-super admins
supportedDelegationTypes: delegationTypeSuperUserFilter(
clientDto.supportedDelegationTypes ?? [],
),
}
}

const {
customClaims,
displayName,
Expand Down Expand Up @@ -600,7 +585,7 @@ export class AdminClientsService {
client.supportedDelegationTypes?.map(
(clientDelegationType) => clientDelegationType.delegationType,
) ?? [],
allowedAcr: client.allowedAcr ?? [],
allowedAcr: client.allowedAcr.map((v) => v.toString()) ?? [],
GunnlaugurG marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading