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)
| 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. |
| 321 | func (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. |
| 336 | func GetTokenFromHeaders(headers http.Header) (string, error) { |