Skip to content

Commit

Permalink
Merge pull request #12 from Evernorth/DeleteFix
Browse files Browse the repository at this point in the history
Fix delete registration (status code, empty grant_types); add log sta…
  • Loading branch information
TomLoomis-Evernorth authored Nov 12, 2024
2 parents 0c83591 + eeacd93 commit e44f865
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions aws/tdcr_udap.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports.clientRegistrationHandler = async (event, context) => {
console.log("Registration request validated.")
if (result == null) {
//new registration

console.log("Performing application create.")
await tdcr_udapLib.validateClientRegistrationMetaData(validatedRegistrationData.verifiedJwt, false, dataHolderOrIdpMode)
clientId = await oauthPlatform.createClientApp(validatedRegistrationData.verifiedJwt, resourceServerId, validatedRegistrationData.verifiedJwtJwks, oauthPlatformManagementClient)
//TODO: Scope handling needs to happen somewhere in here.
Expand All @@ -41,7 +41,7 @@ module.exports.clientRegistrationHandler = async (event, context) => {
}
else if(validatedRegistrationData.verifiedJwt.body.grant_types.length > 0) {
//update/edit registration

console.log("Peforming application edit/update.")
await tdcr_udapLib.validateClientRegistrationMetaData(validatedRegistrationData.verifiedJwt, true, dataHolderOrIdpMode)

clientId = result.client_application_id
Expand All @@ -51,11 +51,12 @@ module.exports.clientRegistrationHandler = async (event, context) => {
}
else {
//No grant types given - delete registration.
console.log('Performing application delete.')
clientId = result.client_application_id
await oauthPlatform.deleteClientApp(result.client_application_id, resourceServerId, oauthPlatformManagementClient)
await deleteSanRegistry(validatedRegistrationData.subjectAlternativeName)

returnStatus = '204'
returnStatus = '200'
}

//TODO: does this merge work if we change scopes? e.g. do not return what was requested which is what happens today.
Expand Down
2 changes: 1 addition & 1 deletion lib/tdcr_udap.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module.exports.validateClientRegistrationMetaData = async (jwtDetails, editMode,
}

//grant_types array is required, but only for creates, not edits. For edits, an empty grant types array means delete.
if (!editMode && (!ssJwtBody.hasOwnProperty('grant_types') || ssJwtBody.grant_types == ''))
if (!editMode && !ssJwtBody.hasOwnProperty('grant_types'))
{
error.message = 'Missing grant_types'
console.error(error)
Expand Down

0 comments on commit e44f865

Please sign in to comment.