Validate existing passwords

This commit is contained in:
Adria Navarro 2025-03-19 15:47:53 +01:00
parent e6612b2a9c
commit 71aecfb51b
3 changed files with 11 additions and 1 deletions

View File

@ -88,6 +88,15 @@ export async function validate(
clientSecret: body.clientSecret, clientSecret: body.clientSecret,
} }
if (config.clientSecret === PASSWORD_REPLACEMENT && body.id) {
const existingConfig = await sdk.oauth2.get(body.id)
if (!existingConfig) {
ctx.throw(`OAuth2 config with id '${body.id}' not found.`, 404)
}
config.clientSecret = existingConfig.clientSecret
}
const validation = await sdk.oauth2.validateConfig(config) const validation = await sdk.oauth2.validateConfig(config)
ctx.status = 201 ctx.status = 201
ctx.body = validation ctx.body = validation

View File

@ -39,7 +39,7 @@ router.delete(
controller.remove controller.remove
) )
router.post( router.post(
"/api/oauth2/:id/validate", "/api/oauth2/validate",
authorized(PermissionType.BUILDER), authorized(PermissionType.BUILDER),
controller.validate controller.validate
) )

View File

@ -22,6 +22,7 @@ export interface UpsertOAuth2ConfigResponse {
} }
export interface ValidateConfigRequest { export interface ValidateConfigRequest {
id?: string
url: string url: string
clientId: string clientId: string
clientSecret: string clientSecret: string