GetToken retrieves the registry JWT token using cryptographic authentication
(ctx context.Context)
| 65 | |
| 66 | // GetToken retrieves the registry JWT token using cryptographic authentication |
| 67 | func (c *CryptoProvider) GetToken(ctx context.Context) (string, error) { |
| 68 | if c.domain == "" { |
| 69 | return "", fmt.Errorf("%s domain is required", c.authMethod) |
| 70 | } |
| 71 | |
| 72 | // Generate current timestamp |
| 73 | timestamp, signedTimestamp, err := c.signer.GetSignedTimestamp(ctx) |
| 74 | if err != nil { |
| 75 | return "", fmt.Errorf("failed to sign timestamp: %w", err) |
| 76 | } |
| 77 | signedTimestampHex := hex.EncodeToString(signedTimestamp) |
| 78 | |
| 79 | // Exchange signature for registry token |
| 80 | registryToken, err := c.exchangeTokenForRegistry(ctx, c.domain, *timestamp, signedTimestampHex) |
| 81 | if err != nil { |
| 82 | return "", fmt.Errorf("failed to exchange %s signature: %w", c.authMethod, err) |
| 83 | } |
| 84 | |
| 85 | return registryToken, nil |
| 86 | } |
| 87 | |
| 88 | type InProcessSigner struct { |
| 89 | privateKey []byte |
nothing calls this directly
no test coverage detected