jwt profile and fixes

This commit is contained in:
Livio Amstutz 2022-04-06 08:49:08 +02:00
parent d91fe7aacf
commit 8b1d405f91
No known key found for this signature in database
GPG key ID: 26BB1C2FA5952CF0
5 changed files with 168 additions and 168 deletions

View file

@ -25,13 +25,13 @@ type AuthRequest struct {
ApplicationID string
CallbackURI string
TransferState string
Prompt []Prompt
Prompt []string
UiLocales []language.Tag
LoginHint string
MaxAuthAge *time.Duration
UserID string
Scopes []string
ResponseType OIDCResponseType
ResponseType oidc.ResponseType
Nonce string
CodeChallenge *OIDCCodeChallenge
@ -80,7 +80,7 @@ func (a *AuthRequest) GetRedirectURI() string {
}
func (a *AuthRequest) GetResponseType() oidc.ResponseType {
return ResponseTypeToOIDC(a.ResponseType)
return a.ResponseType
}
func (a *AuthRequest) GetResponseMode() oidc.ResponseMode {
@ -103,54 +103,20 @@ func (a *AuthRequest) Done() bool {
return a.passwordChecked //this example only uses password for authentication
}
type Prompt int32
const (
PromptUnspecified Prompt = iota
PromptNone
PromptLogin
PromptConsent
PromptSelectAccount
)
func PromptToInternal(oidcPrompt oidc.SpaceDelimitedArray) []Prompt {
prompts := make([]Prompt, len(oidcPrompt))
func PromptToInternal(oidcPrompt oidc.SpaceDelimitedArray) []string {
prompts := make([]string, len(oidcPrompt))
for _, oidcPrompt := range oidcPrompt {
switch oidcPrompt {
case oidc.PromptNone:
prompts = append(prompts, PromptNone)
case oidc.PromptLogin:
prompts = append(prompts, PromptLogin)
case oidc.PromptConsent:
prompts = append(prompts, PromptConsent)
case oidc.PromptSelectAccount:
prompts = append(prompts, PromptSelectAccount)
case oidc.PromptNone,
oidc.PromptLogin,
oidc.PromptConsent,
oidc.PromptSelectAccount:
prompts = append(prompts, oidcPrompt)
}
}
return prompts
}
type OIDCResponseType int32
const (
OIDCResponseTypeCode OIDCResponseType = iota
OIDCResponseTypeIDToken
OIDCResponseTypeIDTokenToken
)
func ResponseTypeToInternal(responseType oidc.ResponseType) OIDCResponseType {
switch responseType {
case oidc.ResponseTypeCode:
return OIDCResponseTypeCode
case oidc.ResponseTypeIDTokenOnly:
return OIDCResponseTypeIDToken
case oidc.ResponseTypeIDToken:
return OIDCResponseTypeIDTokenToken
default:
return OIDCResponseTypeCode
}
}
func MaxAgeToInternal(maxAge *uint) *time.Duration {
if maxAge == nil {
return nil
@ -159,13 +125,6 @@ func MaxAgeToInternal(maxAge *uint) *time.Duration {
return &dur
}
type AuthRequestOIDC struct {
Scopes []string
ResponseType interface{}
Nonce string
CodeChallenge *OIDCCodeChallenge
}
func authRequestToInternal(authReq *oidc.AuthRequest, userID string) *AuthRequest {
return &AuthRequest{
CreationDate: time.Now(),
@ -178,7 +137,7 @@ func authRequestToInternal(authReq *oidc.AuthRequest, userID string) *AuthReques
MaxAuthAge: MaxAgeToInternal(authReq.MaxAge),
UserID: userID,
Scopes: authReq.Scopes,
ResponseType: ResponseTypeToInternal(authReq.ResponseType),
ResponseType: authReq.ResponseType,
Nonce: authReq.Nonce,
CodeChallenge: &OIDCCodeChallenge{
Challenge: authReq.CodeChallenge,
@ -206,19 +165,6 @@ func CodeChallengeToOIDC(challenge *OIDCCodeChallenge) *oidc.CodeChallenge {
}
}
func ResponseTypeToOIDC(responseType OIDCResponseType) oidc.ResponseType {
switch responseType {
case OIDCResponseTypeCode:
return oidc.ResponseTypeCode
case OIDCResponseTypeIDTokenToken:
return oidc.ResponseTypeIDToken
case OIDCResponseTypeIDToken:
return oidc.ResponseTypeIDTokenOnly
default:
return oidc.ResponseTypeCode
}
}
//RefreshTokenRequestFromBusiness will simply wrap the internal RefreshToken to implement the op.RefreshTokenRequest interface
func RefreshTokenRequestFromBusiness(token *RefreshToken) op.RefreshTokenRequest {
return &RefreshTokenRequest{token}