Skip to content

Commit 2f89b91

Browse files
fix(auth): improve JWT and GitHub OIDC token handling (#2832)
Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
1 parent 380e98e commit 2f89b91

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎pkg/attestation/crafter/runners/oidc/github.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2025 The Chainloop Authors.
2+
// Copyright 2025-2026 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -173,6 +173,7 @@ func (c *GitHubOIDCClient) Token(ctx context.Context) (any, error) {
173173
if err != nil {
174174
return nil, fmt.Errorf("error decoding token: %w", err)
175175
}
176+
token.RawToken = tokenPayload
176177

177178
if err := c.verifyClaims(token); err != nil {
178179
return nil, fmt.Errorf("error verifying claims: %w", err)

‎pkg/middlewares/http/jwt.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ func AuthFromAuthorizationHeader(keyFunc jwt.Keyfunc, claimsFunc ClaimsFunc, sig
8484
func verifyAndMarshalJWT(token string, keyFunc jwt.Keyfunc, claimsFunc ClaimsFunc, signingMethod jwt.SigningMethod) (*jwt.Claims, error) {
8585
var tokenInfo *jwt.Token
8686

87+
if token == "" {
88+
return nil, jwtMiddleware.ErrTokenInvalid
89+
}
90+
8791
tokenInfo, err := jwt.ParseWithClaims(token, claimsFunc(), keyFunc)
8892
if err != nil {
8993
var ve *jwt.ValidationError

0 commit comments

Comments
 (0)