mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-08 17:37:01 +00:00
refactor: move scopes to own pkg
This commit is contained in:
29
pkg/scopes/scopes.go
Normal file
29
pkg/scopes/scopes.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package scopes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
OpenID = "openid"
|
||||
AzureAPITemplate = "api://%s/.default"
|
||||
)
|
||||
|
||||
type Scopes []string
|
||||
|
||||
func (s Scopes) String() string {
|
||||
return strings.Join(s, " ")
|
||||
}
|
||||
|
||||
func (s Scopes) WithAdditional(scopes ...string) Scopes {
|
||||
return append(s, scopes...)
|
||||
}
|
||||
|
||||
func (s Scopes) WithAzureScope(clientID string) Scopes {
|
||||
return append(s, fmt.Sprintf(AzureAPITemplate, clientID))
|
||||
}
|
||||
|
||||
func Defaults() Scopes {
|
||||
return []string{OpenID}
|
||||
}
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
const ScopeOpenID = "openid"
|
||||
|
||||
type IDToken struct {
|
||||
Raw string
|
||||
Token jwt.Token
|
||||
|
||||
Reference in New Issue
Block a user