AuthN: Add last seen sync hooks for user and api keys (#61571)

* AUthN: Add last seen sync hooks for user / service account and move api
key last seen to own hook

* ContextHandler: only run sync for last seen if auth.Service is not
enabled
This commit is contained in:
Karl Persson
2023-01-17 13:50:58 +01:00
committed by GitHub
parent ac25913f53
commit 766fa4e7d5
5 changed files with 98 additions and 16 deletions
-11
View File
@@ -56,17 +56,6 @@ func (s *APIKey) Authenticate(ctx context.Context, r *authn.Request) (*authn.Ide
return nil, errAPIKeyRevoked.Errorf("Api key is revoked")
}
go func(id int64) {
defer func() {
if err := recover(); err != nil {
s.log.Error("api key authentication panic", "err", err)
}
}()
if err := s.apiKeyService.UpdateAPIKeyLastUsedDate(context.Background(), id); err != nil {
s.log.Warn("failed to update last use date for api key", "id", id)
}
}(apiKey.Id)
// if the api key don't belong to a service account construct the identity and return it
if apiKey.ServiceAccountId == nil || *apiKey.ServiceAccountId < 1 {
return &authn.Identity{