Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth: increase verbosity of oidc parsing errors #4599

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading