Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
cleanup resources on accessrequest deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Apr 14, 2023
1 parent d4701a7 commit 556881b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/discovery/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func initConfig(centralConfig corecfg.CentralConfig) (interface{}, error) {
agent.NewAPIKeyAccessRequestBuilder().Register()

agent.NewAPIKeyCredentialRequestBuilder(coreagent.WithCRDRequestSchemaProperty(corsProp)).IsRenewable().Register()

oAuthRedirects := getAuthRedirectSchemaPropertyBuilder()

oAuthServers := provisioning.NewSchemaPropertyBuilder().
Expand Down
9 changes: 7 additions & 2 deletions pkg/subscription/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (p provisioner) AccessRequestDeprovision(req prov.AccessRequest) prov.Reque
}

// process access request delete
webmethodsApplicationId := req.GetApplicationDetailsValue(common.AttrAppID)
webmethodsApplicationId := req.GetAccessRequestDetailsValue(common.AttrAppID)
//GetApplicationDetailsValue(common.AttrAppID)
if webmethodsApplicationId == "" {
return p.failed(rs, notFound(common.AttrAppID))
}
Expand Down Expand Up @@ -163,7 +164,7 @@ func (p provisioner) ApplicationRequestProvision(req prov.ApplicationRequest) pr
if err != nil {
return p.failed(rs, notFound("Error creating application"))
}
applicationId = createdApplication.ApplicationID
applicationId = createdApplication.Id
} else {
log.Infof("Using the exsting application with Id %s", searchAppResponse.SearchApplication[0].ApplicationID)
applicationId = searchAppResponse.SearchApplication[0].ApplicationID
Expand Down Expand Up @@ -200,6 +201,10 @@ func (p provisioner) CredentialDeprovision(req prov.CredentialRequest) prov.Requ
case OAuth2AuthType:
log.Info("Removing oauth credential")
applicationsResponse, err := p.client.GetApplication(webmethodsApplicationId)
if len(applicationsResponse.Applications) == 0 {
log.Warnf("Unable to find webmethods application with Id %s", webmethodsApplicationId)
return rs.Success()
}
if err != nil {
return p.failed(rs, notFound("Unable to get application from Webmethods"))
}
Expand Down

0 comments on commit 556881b

Please sign in to comment.