From f93337e99b87e53d09f564ce615bbb30f8ea8179 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Thu, 8 Jul 2021 18:38:34 +0200 Subject: [PATCH] fix: race condition in auth request unmarshalling (#1993) --- internal/domain/auth_request.go | 8 ++++---- internal/domain/request.go | 6 ------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/internal/domain/auth_request.go b/internal/domain/auth_request.go index 38363ff09a..8e0c031415 100644 --- a/internal/domain/auth_request.go +++ b/internal/domain/auth_request.go @@ -111,11 +111,11 @@ const ( ) func NewAuthRequestFromType(requestType AuthRequestType) (*AuthRequest, error) { - request, ok := authRequestTypeMapping[requestType] - if !ok { - return nil, errors.ThrowInvalidArgument(nil, "DOMAIN-ds2kl", "invalid request type") + switch requestType { + case AuthRequestTypeOIDC: + return &AuthRequest{Request: &AuthRequestOIDC{}}, nil } - return &AuthRequest{Request: request}, nil + return nil, errors.ThrowInvalidArgument(nil, "DOMAIN-ds2kl", "invalid request type") } func (a *AuthRequest) WithCurrentInfo(info *BrowserInfo) *AuthRequest { diff --git a/internal/domain/request.go b/internal/domain/request.go index b31d85fe57..c0bfd69bfd 100644 --- a/internal/domain/request.go +++ b/internal/domain/request.go @@ -15,12 +15,6 @@ type Request interface { type AuthRequestType int32 -var ( - authRequestTypeMapping = map[AuthRequestType]Request{ - AuthRequestTypeOIDC: &AuthRequestOIDC{}, - } -) - const ( AuthRequestTypeOIDC AuthRequestType = iota AuthRequestTypeSAML