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

Commit

Permalink
add audience field to oauth auth
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Apr 14, 2023
1 parent 93af0c1 commit 5190ea6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
18 changes: 8 additions & 10 deletions pkg/cmd/discovery/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,15 @@ func initConfig(centralConfig corecfg.CentralConfig) (interface{}, error) {
oAuthRedirects := getAuthRedirectSchemaPropertyBuilder()

oAuthServers := provisioning.NewSchemaPropertyBuilder().
SetName(subscription.OauthServerField).
SetRequired().
SetLabel("Oauth Server").
IsString().
SetEnumValues(servers)
SetName(subscription.OauthServerField).SetRequired().SetLabel("Oauth Server").
IsString().SetEnumValues(servers)

oAuthType := provisioning.NewSchemaPropertyBuilder().
SetName(subscription.ApplicationTypeField).
SetRequired().
SetLabel("Application Type").
IsString().
SetEnumValues([]string{"Confidential", "Public"})
SetName(subscription.ApplicationTypeField).SetRequired().SetLabel("Application Type").
IsString().SetEnumValues([]string{"Confidential", "Public"}).SetFirstEnumValue("Confidential")

audience := provisioning.NewSchemaPropertyBuilder().
SetName(subscription.AudienceField).SetLabel("Audience").IsString().SetAsTextArea()

agent.NewAccessRequestBuilder().SetName(subscription.OAuth2AuthType).Register()

Expand All @@ -114,6 +111,7 @@ func initConfig(centralConfig corecfg.CentralConfig) (interface{}, error) {
coreagent.WithCRDOAuthSecret(),
coreagent.WithCRDRequestSchemaProperty(oAuthServers),
coreagent.WithCRDRequestSchemaProperty(oAuthType),
coreagent.WithCRDRequestSchemaProperty(audience),
coreagent.WithCRDRequestSchemaProperty(oAuthRedirects),
coreagent.WithCRDRequestSchemaProperty(corsProp)).SetName(subscription.OAuth2AuthType).IsRenewable().Register()

Expand Down
9 changes: 8 additions & 1 deletion pkg/subscription/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
ApplicationTypeField = "applicationType"
// ClientTypeField -
ClientTypeField = "clientType"
AudienceField = "audience"
)

type provisioner struct {
Expand Down Expand Up @@ -300,6 +301,11 @@ func getCredProvData(credData map[string]interface{}) credentialMetaData {
credMetaData.appType = data.(string)
}

// Audience type field
if data, ok := credData[AudienceField]; ok && data != nil {
credMetaData.audience = data.(string)
}

return credMetaData
}

Expand All @@ -308,6 +314,7 @@ type credentialMetaData struct {
redirectURLs []string
oauthServerName string
appType string
audience string
}

func createOrGetOauthCredential(application webmethods.Application, provData credentialMetaData, p provisioner) (prov.Credential, error) {
Expand All @@ -332,7 +339,7 @@ func createOrGetOauthCredential(application webmethods.Application, provData cre
Name: application.Name,
Description: application.Name,
AuthServerAlias: provData.oauthServerName,
Audience: "",
Audience: provData.audience,
Type: "OAUTH2",
DcrConfig: dcrconfig,
}
Expand Down

0 comments on commit 5190ea6

Please sign in to comment.