Skip to content

Commit

Permalink
fix: Clear webauthn session data at EOL
Browse files Browse the repository at this point in the history
Signed-off-by: jay-dee7 <[email protected]>
  • Loading branch information
jay-dee7 committed Dec 24, 2023
1 parent 9755b13 commit 25f5c0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions auth/webauthn/webauthn.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func (wa *webAuthnService) FinishRegistration(ctx context.Context, opts *FinishR
return fmt.Errorf("ERR_WEBAUTHN_ADD_CREDENTIAL: %w", err)
}

if err = wa.store.RemoveWebAuthSessionData(ctx, opts.User.ID); err != nil {
return fmt.Errorf("ERR_WEBAUTHN_ADD_CREDENTIAL: RemoveWebAuthSessionData: %w", err)
}

return nil
}

Expand Down Expand Up @@ -306,5 +310,9 @@ func (wa *webAuthnService) FinishLogin(ctx context.Context, opts *FinishLoginOpt
return fmt.Errorf("ERR_VALIDATE_WEBAUTHN_LOGIN: %w", err)
}

if err = wa.store.RemoveWebAuthSessionData(ctx, opts.User.ID); err != nil {
return fmt.Errorf("ERR_WEBAUTHN_ADD_CREDENTIAL: RemoveWebAuthSessionData: %w", err)
}

return nil
}
3 changes: 2 additions & 1 deletion services/yor/clair/v1/server/interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ func (c *clair) NewJWTInterceptor() connect.UnaryInterceptorFunc {

userID, err := c.getTokenFromReq(req, c.authConfig.JWTSigningPubKey)
if err != nil {
logEvent.Err(err).Send()
return nil, err
}

user, err := c.userGetter.GetUserByID(ctx, userID)
if err != nil {
logEvent.Str("error", err.Error()).Send()
logEvent.Err(err).Send()
return nil, connect.NewError(connect.CodeFailedPrecondition, err)
}

Expand Down

0 comments on commit 25f5c0d

Please sign in to comment.