Commit 65b80521 authored by ale's avatar ale

Log the case when a user has no keys (but Open still succeeds)

parent 128c384b
Pipeline #899 passed with stages
in 48 seconds
......@@ -150,7 +150,7 @@ func (s *KeyStore) Open(ctx context.Context, username, password string, ttlSecon
}
if len(encKeys) == 0 {
// No keys found. Not an error.
return nil
return errNoKeys
}
// Naive and inefficient way of decrypting multiple keys: it
......
......@@ -22,13 +22,16 @@ func (s *keyStoreServer) handleOpen(w http.ResponseWriter, r *http.Request) {
}
err := s.KeyStore.Open(r.Context(), req.Username, req.Password, req.TTL)
if err != nil {
if err == errNoKeys {
log.Printf("no keys found for %s", req.Username)
} else if err != nil {
log.Printf("Open(%s) error: %v", req.Username, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else {
log.Printf("decrypted key for %s, ttl=%d", req.Username, req.TTL)
}
log.Printf("decrypted key for %s, ttl=%d", req.Username, req.TTL)
serverutil.EncodeJSONResponse(w, &emptyResponse)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment