Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-13535/TT-13566] Make upstream oauth flow client secret omitempty #6708

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apidef/api_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ type ClientAuthData struct {
// ClientID is the application's ID.
ClientID string `bson:"client_id" json:"client_id"`
// ClientSecret is the application's secret.
ClientSecret string `bson:"client_secret" json:"client_secret"`
ClientSecret string `bson:"client_secret,omitempty" json:"client_secret,omitempty"` // client secret is optional for password flow
}

// ClientCredentials holds the client credentials for upstream OAuth2 authentication.
Expand Down
22 changes: 22 additions & 0 deletions apidef/api_definitions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ func TestSchema(t *testing.T) {
schemaLoader := schema.NewBytesLoader([]byte(Schema))

spec := DummyAPI()
spec.UpstreamAuth = UpstreamAuth{
Enabled: true,
OAuth: UpstreamOAuth{
Enabled: true,
ClientCredentials: ClientCredentials{
ClientAuthData: ClientAuthData{
ClientSecret: "dummy", // workaround to fix schema error
},
},
},
}
goLoader := schema.NewGoLoader(spec)
result, err := schema.Validate(schemaLoader, goLoader)
if err != nil {
Expand Down Expand Up @@ -100,6 +111,17 @@ func TestSchemaGraphqlConfig(t *testing.T) {
schemaLoader := schema.NewBytesLoader([]byte(Schema))

spec := DummyAPI()
spec.UpstreamAuth = UpstreamAuth{
Enabled: true,
OAuth: UpstreamOAuth{
Enabled: true,
ClientCredentials: ClientCredentials{
ClientAuthData: ClientAuthData{
ClientSecret: "dummy", // workaround to fix schema error
},
},
},
}
spec.GraphQL.ExecutionMode = ""

goLoader := schema.NewGoLoader(spec)
Expand Down
2 changes: 1 addition & 1 deletion apidef/oas/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ type ClientAuthData struct {
// ClientID is the application's ID.
ClientID string `bson:"clientId" json:"clientId"`
// ClientSecret is the application's secret.
ClientSecret string `bson:"clientSecret" json:"clientSecret"`
ClientSecret string `bson:"clientSecret,omitempty" json:"clientSecret,omitempty"` // client secret is optional for password flow
}

// ClientCredentials holds the configuration for OAuth2 Client Credentials flow.
Expand Down
1 change: 0 additions & 1 deletion apidef/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,6 @@ const Schema = `{
},
"required": [
"client_id",
"client_secret",
"token_url",
"username",
"password"
Expand Down
Loading