refactor: move scopes to own pkg

This commit is contained in:
Trong Huu Nguyen
2021-10-16 10:27:17 +02:00
parent 8711f6e0d3
commit 9b15da6251
2 changed files with 29 additions and 2 deletions

29
pkg/scopes/scopes.go Normal file
View 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}
}

View File

@@ -8,8 +8,6 @@ import (
"golang.org/x/oauth2"
)
const ScopeOpenID = "openid"
type IDToken struct {
Raw string
Token jwt.Token