MCPcopy Index your code
hub / github.com/bytebase/bytebase / AuthenticateToken

Method AuthenticateToken

backend/api/auth/auth.go:321–333  ·  view source on GitHub ↗

AuthenticateToken validates a JWT access token and returns the user and token expiry. This is a non-ConnectRPC version that returns regular errors instead of ConnectRPC errors.

(ctx context.Context, accessTokenStr string)

Source from the content-addressed store, hash-verified

319// AuthenticateToken validates a JWT access token and returns the user and token expiry.
320// This is a non-ConnectRPC version that returns regular errors instead of ConnectRPC errors.
321func (in *APIAuthInterceptor) AuthenticateToken(ctx context.Context, accessTokenStr string) (*store.UserMessage, string, time.Time, error) {
322 user, claims, err := in.authenticate(ctx, accessTokenStr)
323 if err != nil {
324 return nil, "", time.Time{}, err
325 }
326
327 var tokenExpiry time.Time
328 if claims.ExpiresAt != nil {
329 tokenExpiry = claims.ExpiresAt.Time
330 }
331
332 return user, claims.WorkspaceID, tokenExpiry, nil
333}
334
335// GetTokenFromHeaders extracts the access token from HTTP headers for ConnectRPC.
336func GetTokenFromHeaders(headers http.Header) (string, error) {

Callers 1

RouterMethod · 0.80

Calls 1

authenticateMethod · 0.95

Tested by

no test coverage detected