Skip to content
Open
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
6 changes: 5 additions & 1 deletion swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type OAuthConfig struct {

// The name to display for the application in the authentication popup.
AppName string

// Use the Proof Key for Code Exchange extension to the authorization code flow
UsePkce bool
}

// URL presents the url pointing to API definition (normally swagger.json or swagger.yaml).
Expand Down Expand Up @@ -286,7 +289,8 @@ window.onload = function() {
ui.initOAuth({
clientId: "{{.OAuth.ClientId}}",
realm: "{{.OAuth.Realm}}",
appName: "{{.OAuth.AppName}}"
appName: "{{.OAuth.AppName}}",
usePkceWithAuthorizationCodeGrant: {{.OAuth.UsePkce}}
})
{{end}}

Expand Down
5 changes: 4 additions & 1 deletion swagger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ func TestConfigWithOAuth(t *testing.T) {
assert.Contains(t, body, `ui.initOAuth({
clientId: "my-client-id",
realm: "my-realm",
appName: "My App Name"
appName: "My App Name",
usePkceWithAuthorizationCodeGrant: false
})`)
}

Expand Down Expand Up @@ -419,11 +420,13 @@ func TestOAuth(t *testing.T) {
ClientId: "my-client-id",
Realm: "my-realm",
AppName: "My App Name",
UsePkce: true,
}
OAuth(&expected)(&cfg)
assert.Equal(t, expected.ClientId, cfg.OAuth.ClientId)
assert.Equal(t, expected.Realm, cfg.OAuth.Realm)
assert.Equal(t, expected.AppName, cfg.OAuth.AppName)
assert.Equal(t, expected.UsePkce, cfg.OAuth.UsePkce)
}

func TestOAuthNil(t *testing.T) {
Expand Down