MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / Sign

Method Sign

internal/agentauth/signing.go:75–95  ·  view source on GitHub ↗

Sign issues an RS256 JWT carrying the given claims, with the kid in the header so verifiers can select the right JWKS entry. Returns ErrSigningDisabled when no key is configured.

(claims jwt.Claims, private map[string]interface{})

Source from the content-addressed store, hash-verified

73// header so verifiers can select the right JWKS entry. Returns
74// ErrSigningDisabled when no key is configured.
75func (s *Signer) Sign(claims jwt.Claims, private map[string]interface{}) (string, error) {
76 if !s.Enabled() {
77 return "", ErrSigningDisabled
78 }
79 sig, err := jose.NewSigner(
80 jose.SigningKey{Algorithm: SigningAlg, Key: jose.JSONWebKey{Key: s.priv, KeyID: s.kid}},
81 (&jose.SignerOptions{}).WithType("JWT"),
82 )
83 if err != nil {
84 return "", fmt.Errorf("agentauth: build signer: %w", err)
85 }
86 builder := jwt.Signed(sig).Claims(claims)
87 if len(private) > 0 {
88 builder = builder.Claims(private)
89 }
90 out, err := builder.CompactSerialize()
91 if err != nil {
92 return "", fmt.Errorf("agentauth: serialize jwt: %w", err)
93 }
94 return out, nil
95}
96
97// PublicJWKS returns the public half as a JWK set for /.well-known/jwks.json.
98// When disabled it returns an empty (non-nil) set so the endpoint always serves

Calls 1

EnabledMethod · 0.95