Skip to content

Commit

Permalink
APIGOV-27834 - fix to register CRD for external IdP (#769)
Browse files Browse the repository at this point in the history
* APIGOV-27834 - fix to register CRD for external IdP with supported scopes

* APIGOV-27834 - Fix for specHash on CRD
- The required property in the schema is created using map of properties and this cause sort order on the array items to change resulting in different spec hash computed even with same values
- Fix to order the required property items
  • Loading branch information
vivekschauhan authored May 2, 2024
1 parent 3a38952 commit 2a4612e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@ func registerCredentialProvider(idp config.IDPConfig, tlsCfg config.TLSConfig, p
Errorf("unable to register external IdP provider, any credential request to the IdP will not be processed. %s", err.Error())
}
crdName := idp.GetIDPName() + " " + provisioning.OAuthIDPCRD

provider, err := GetAuthProviderRegistry().GetProviderByName(idp.GetIDPName())
if err != nil {
return err
}
crd, err := NewOAuthCredentialRequestBuilder(
WithCRDName(crdName),
WithCRDTitle(idp.GetIDPTitle()),
WithCRDForIDP(provider, provider.GetSupportedScopes()),
WithCRDOAuthSecret(),
WithCRDRequestSchemaProperty(getCorsSchemaPropertyBuilder()),
WithCRDRequestSchemaProperty(getAuthRedirectSchemaPropertyBuilder()),
Expand Down
3 changes: 3 additions & 0 deletions pkg/apic/provisioning/propertybuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,9 @@ func (p *objectSchemaProperty) Build() (def *propertyDefinition, err error) {
}
}
}
if len(requiredProperties) > 0 {
sort.Strings(requiredProperties)
}

def.Properties = p.properties
def.RequiredProperties = requiredProperties
Expand Down
3 changes: 2 additions & 1 deletion pkg/apic/provisioning/schemabuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package provisioning

import (
"encoding/json"
"sort"

"github.com/Axway/agent-sdk/pkg/util/log"
)
Expand Down Expand Up @@ -158,7 +159,7 @@ func (s *schemaBuilder) Build() (map[string]interface{}, error) {
required = append(required, key)
}
}

sort.Strings(required)
schema := &jsonSchema{
SubscriptionName: s.name,
SchemaType: "object",
Expand Down

0 comments on commit 2a4612e

Please sign in to comment.