Skip to content

Commit

Permalink
Updated logging statements in rewrap.go
Browse files Browse the repository at this point in the history
The logging statements in the "getEntityInfo" and "Rewrap" functions of rewrap.go have been updated for increased clarity and more detailed error tracking. This includes changing the level of some logs from 'warn' to 'error' when an issue arises while obtaining a token, and adding more context information to debug logs.
  • Loading branch information
arkavo-com committed May 11, 2024
1 parent e9b6649 commit 9cc6830
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions service/kas/access/rewrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ func getEntityInfo(ctx context.Context) (*entityInfo, error) {
if len(header) < 1 {
return nil, status.Error(codes.Unauthenticated, "missing authorization header")
}
slog.DebugContext(ctx, "header", header[0])
slog.DebugContext(ctx, "getEntityInfo", "header", header[0])
tokenRaw = strings.TrimPrefix(header[0], "DPoP ")
tokenRaw = strings.TrimPrefix(header[0], "Bearer ")
slog.DebugContext(ctx, "tokenRaw", tokenRaw)
slog.DebugContext(ctx, "getEntityInfo", "tokenRaw", tokenRaw)
token, err := jwt.ParseInsecure([]byte(tokenRaw))
if err != nil {
slog.WarnContext(ctx, "unable to get token")
slog.ErrorContext(ctx, "unable to get token")
return nil, errors.New("unable to get token")
}

Expand All @@ -217,21 +217,22 @@ func getEntityInfo(ctx context.Context) (*entityInfo, error) {
}

info.Token = tokenRaw

slog.DebugContext(ctx, "getEntityInfo", "info", info)
return info, nil
}

func (p *Provider) Rewrap(ctx context.Context, in *kaspb.RewrapRequest) (*kaspb.RewrapResponse, error) {
slog.DebugContext(ctx, "REWRAP")
slog.Info("kas context", slog.Any("ctx", ctx))

body, err := verifySignedRequestToken(ctx, in)
if err != nil {
slog.ErrorContext(ctx, "Rewrap", "err", err)
return nil, err
}

entityInfo, err := getEntityInfo(ctx)
if err != nil {
slog.ErrorContext(ctx, "Rewrap", "err", err)
return nil, err
}

Expand Down

0 comments on commit 9cc6830

Please sign in to comment.