Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add auth style in backend (#7238)
boojack67ca5f94cb21
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.goindex 25f1cf4fa7..f6f01ef04a 100644--- a/backend/api/v1/auth_service.go+++ b/backend/api/v1/auth_service.go@@ -716,6 +716,7 @@ func (s *AuthService) getOrCreateUserWithIDP(ctx context.Context, request *v1pb.ClientSecret: idp.Config.GetOidcConfig().ClientSecret,FieldMapping: idp.Config.GetOidcConfig().FieldMapping,SkipTLSVerify: idp.Config.GetOidcConfig().SkipTlsVerify,+ AuthStyle: idp.Config.GetOidcConfig().GetAuthStyle(),},)if err != nil {diff --git a/backend/api/v1/idp_service.go b/backend/api/v1/idp_service.goindex 7cfe7e4bf7..6facfea66e 100644--- a/backend/api/v1/idp_service.go+++ b/backend/api/v1/idp_service.go@@ -260,6 +260,7 @@ func (s *IdentityProviderService) TestIdentityProvider(ctx context.Context, requClientSecret: identityProviderConfig.GetOidcConfig().ClientSecret,FieldMapping: identityProviderConfig.GetOidcConfig().FieldMapping,SkipTLSVerify: identityProviderConfig.GetOidcConfig().SkipTlsVerify,+ AuthStyle: identityProviderConfig.GetOidcConfig().GetAuthStyle(),})if err != nil {return nil, status.Errorf(codes.Internal, "failed to create new OIDC identity provider: %v", err)@@ -330,6 +331,7 @@ func convertIdentityProviderConfigFromStore(identityProviderConfig *storepb.IdenScopes: v.Scopes,FieldMapping: &fieldMapping,SkipTlsVerify: v.SkipTlsVerify,+ AuthStyle: v1pb.OAuth2AuthStyle(v.AuthStyle),},},}@@ -348,6 +350,7 @@ func convertIdentityProviderConfigFromStore(identityProviderConfig *storepb.IdenScopes: oidc.DefaultScopes,FieldMapping: &fieldMapping,SkipTlsVerify: v.SkipTlsVerify,+ AuthStyle: v1pb.OAuth2AuthStyle(v.AuthStyle),},},}@@ -373,6 +376,7 @@ func convertIdentityProviderConfigToStore(identityProviderConfig *v1pb.IdentityPScopes: v.Scopes,FieldMapping: &fieldMapping,SkipTlsVerify: v.SkipTlsVerify,+ AuthStyle: storepb.OAuth2AuthStyle(v.AuthStyle),},},}@@ -390,6 +394,7 @@ func convertIdentityProviderConfigToStore(identityProviderConfig *v1pb.IdentityPClientSecret: v.ClientSecret,FieldMapping: &fieldMapping,SkipTlsVerify: v.SkipTlsVerify,+ AuthStyle: storepb.OAuth2AuthStyle(v.AuthStyle),},},}diff --git a/backend/plugin/idp/oauth2/oauth2.go b/backend/plugin/idp/oauth2/oauth2.goindex 3d1fbe2f9e..32b3c46fcf 100644--- a/backend/plugin/idp/oauth2/oauth2.go+++ b/backend/plugin/idp/oauth2/oauth2.go@@ -52,6 +52,10 @@ func NewIdentityProvider(config *storepb.OAuth2IdentityProviderConfig) (*Identit// ExchangeToken returns the exchanged OAuth2 token using the given authorization code.func (p *IdentityProvider) ExchangeToken(ctx context.Context, redirectURL, code string) (string, error) {+ authStyle := oauth2.AuthStyleInParams+ if p.config.GetAuthStyle() == storepb.OAuth2AuthStyle_IN_HEADER {+ authStyle = oauth2.AuthStyleInHeader+ }conf := &oauth2.Config{ClientID: p.config.ClientId,ClientSecret: p.config.ClientSecret,@@ -60,7 +64,7 @@ func (p *IdentityProvider) ExchangeToken(ctx context.Context, redirectURL, codeEndpoint: oauth2.Endpoint{AuthURL: p.config.AuthUrl,TokenURL: p.config.TokenUrl,- AuthStyle: oauth2.AuthStyleInParams,+ AuthStyle: authStyle,},}diff --git a/backend/plugin/idp/oidc/oidc.go b/backend/plugin/idp/oidc/oidc.goindex 8d5c124cc0..2a00319243 100644--- a/backend/plugin/idp/oidc/oidc.go+++ b/backend/plugin/idp/oidc/oidc.go@@ -26,11 +26,12 @@ type IdentityProvider struct {// IdentityProviderConfig is the configuration to be consumed by the OIDC// Identity Provider.type IdentityProviderConfig struct {- Issuer string `json:"issuer"`- ClientID string `json:"clientId"`- ClientSecret string `json:"clientSecret"`- FieldMapping *storepb.FieldMapping `json:"fieldMapping"`- SkipTLSVerify bool `json:"skipTlsVerify"`+ Issuer string `json:"issuer"`+ ClientID string `json:"clientId"`+ ClientSecret string `json:"clientSecret"`+ FieldMapping *storepb.FieldMapping `json:"fieldMapping"`+ SkipTLSVerify bool `json:"skipTlsVerify"`+ AuthStyle storepb.OAuth2AuthStyle `json:"authStyle"`}// NewIdentityProvider initializes a new OIDC Identity Provider with the given@@ -83,6 +84,12 @@ func (p *IdentityProvider) ExchangeToken(ctx context.Context, redirectURL, codeScopes: DefaultScopes,}+ authStyle := oauth2.AuthStyleInParams+ if p.config.AuthStyle == storepb.OAuth2AuthStyle_IN_HEADER {+ authStyle = oauth2.AuthStyleInHeader+ }+ oauth2Config.Endpoint.AuthStyle = authStyle+ctx = context.WithValue(ctx, oauth2.HTTPClient, p.client)token, err := oauth2Config.Exchange(ctx, code)if err != nil {