Skip to content

Commit 9cbbbd4

Browse files
committed
ING-662: Have creds take priority over client cert if both given
1 parent a60bd2e commit 9cbbbd4

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

gateway/dataimpl/server_v1/authhandler.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,13 @@ func (a AuthHandler) MaybeGetOboUserFromContext(ctx context.Context) (string, st
7777
credsFound := username != "" && password != ""
7878
certFound := connState != nil && len(connState.PeerCertificates) != 0
7979

80-
if credsFound && certFound {
81-
return "", "", a.ErrorHandler.NewCredentialsAndCertStatus()
82-
}
83-
84-
if !credsFound && !certFound {
80+
switch {
81+
case !credsFound && !certFound:
8582
return "", "", nil
86-
}
87-
88-
if certFound {
83+
case credsFound && certFound:
84+
a.Logger.Debug("username/password taking priority over client cert auth as both were given.")
85+
case credsFound:
86+
case certFound:
8987
oboUser, oboDomain, err := a.Authenticator.ValidateConnStateForObo(ctx, connState)
9088
if err != nil {
9189
if errors.Is(err, auth.ErrInvalidCertificate) {

gateway/dataimpl/server_v1/errorhandler.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,6 @@ func (e ErrorHandler) NewUnexpectedAuthTypeStatus() *status.Status {
884884
return st
885885
}
886886

887-
func (e ErrorHandler) NewCredentialsAndCertStatus() *status.Status {
888-
st := status.New(codes.InvalidArgument, "Authorization header and client certificate provided.")
889-
return st
890-
}
891-
892887
func (e ErrorHandler) NewInvalidQueryStatus(baseErr error, queryErrStr string) *status.Status {
893888
st := status.New(codes.InvalidArgument,
894889
fmt.Sprintf("Query parsing failed: %s", queryErrStr))

0 commit comments

Comments
 (0)