Files
wonderwall/pkg/openid/scopes/scopes.go
2022-08-26 14:32:39 +02:00

35 lines
598 B
Go

package scopes
import (
"fmt"
"strings"
)
const (
OpenID = "openid"
OfflineAccess = "offline_access"
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 (s Scopes) WithOfflineAccess() Scopes {
return append(s, OfflineAccess)
}
func DefaultScopes() Scopes {
return []string{OpenID}
}