Skip to content

Commit

Permalink
auth: increase verbosity of oidc parsing errors (#4599)
Browse files Browse the repository at this point in the history
* auth: increase verbosity of oidc parsing errors

* Fixed error reporting logic

* Changelog

* eosbinary: changed error reporting, attempting to fix CI
  • Loading branch information
glpatcern authored Apr 15, 2024
1 parent 649f62b commit 8781797
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-auth-log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: auth: increase verbosity of oidc parsing errors

This is to help further debugging of auth issues.
An unrelated error reporting was also fixed.

https://github.com/cs3org/reva/pull/4599
4 changes: 2 additions & 2 deletions pkg/auth/manager/oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (am *mgr) Authenticate(ctx context.Context, _, clientSecret string) (*user.

claims, err := extractClaims(clientSecret)
if err != nil {
return nil, nil, errtypes.PermissionDenied("oidc token not valid")
return nil, nil, errtypes.PermissionDenied(fmt.Sprintf("error extracting claims from oidc token: %+v", err))
}

issuer, ok := extractIssuer(claims)
Expand All @@ -248,7 +248,7 @@ func (am *mgr) Authenticate(ctx context.Context, _, clientSecret string) (*user.

tkn, err := provider.Verifier(config).Verify(ctx, clientSecret)
if err != nil {
return nil, nil, errtypes.PermissionDenied(fmt.Sprintf("oidc token not valid: %+v", err))
return nil, nil, errtypes.PermissionDenied(fmt.Sprintf("oidc token failed verification: %+v", err))
}

sub, err := am.doUserMapping(tkn, claims)
Expand Down
13 changes: 5 additions & 8 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,28 +260,25 @@ func (c *Client) executeEOS(ctx context.Context, cmdArgs []string, auth eosclien
case 0:
err = nil
case int(syscall.ENOENT):
err = errtypes.NotFound(errBuf.String())
err = errtypes.NotFound("eosclient: " + errBuf.String())
case int(syscall.EPERM), int(syscall.E2BIG), int(syscall.EINVAL):
// eos reports back error code 1 (EPERM) when ?
// eos reports back error code 1 (EPERM) as a PermissionDenied error
// eos reports back error code 7 (E2BIG) when the user is not allowed to read the directory
// eos reports back error code 22 (EINVAL) when the user is not allowed to enter the instance
errString := errBuf.String()
if errString == "" {
errString = fmt.Sprintf("rc = %d", exitStatus)
}
err = errtypes.PermissionDenied(errString)
err = errtypes.PermissionDenied("eosclient: " + errString)
default:
err = errors.Wrap(err, fmt.Sprintf("eosclient: error while executing command: %s", errBuf.String()))
}
}
}

args := fmt.Sprintf("%s", cmd.Args)
env := fmt.Sprintf("%s", cmd.Env)
log.Info().Str("args", args).Str("env", env).Int("exit", exitStatus).Str("err", errBuf.String()).Msg("eos cmd")

if err != nil && exitStatus != int(syscall.ENOENT) { // don't wrap the errtypes.NotFoundError
err = errors.Wrap(err, "eosclient: error while executing command")
}

return outBuf.String(), errBuf.String(), err
}

Expand Down

0 comments on commit 8781797

Please sign in to comment.