Documentation
¶
Index ¶
Constants ¶
const ( // EVMAddressClaim carries the authenticated EVM address. EVMAddressClaim = "evm_address" // CantonPartyClaim carries the user's Canton party id. It mirrors the standard // "sub" claim but is named explicitly so external verifiers (e.g. the indexer) // can read the party without relying on "sub" semantics. CantonPartyClaim = "canton_party_id" )
Custom JWT claims carried alongside the registered claims.
Variables ¶
This section is empty.
Functions ¶
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(pemString string) (*rsa.PrivateKey, error)
ParseRSAPrivateKey decodes a PEM-encoded RSA private key in either PKCS#1 ("RSA PRIVATE KEY") or PKCS#8 ("PRIVATE KEY") form.
func RequireAuth ¶
RequireAuth returns middleware that rejects requests without a valid bearer token for the expected audience and populates the request context with the authenticated identity (EVM address + Canton party) from the token claims.
Types ¶
type Claims ¶
type Claims struct {
EVMAddress string `json:"evm_address"`
CantonPartyID string `json:"canton_party_id"`
gojwt.RegisteredClaims
}
Claims are the claims minted at login. The Canton party id is both the subject and an explicit canton_party_id claim; the EVM address rides alongside so handlers can resolve either identity from the token.
type Issuer ¶
type Issuer struct {
// contains filtered or unexported fields
}
Issuer mints RS256 JWTs for authenticated users.
func (*Issuer) Issue ¶
Issue mints a signed token for the (evmAddress, cantonPartyID) identity and returns it alongside its expiry time.
type JWK ¶
type JWK struct {
Kid string `json:"kid"`
Kty string `json:"kty"`
Alg string `json:"alg"`
Use string `json:"use"`
N string `json:"n"`
E string `json:"e"`
}
JWK is a single JSON Web Key (RSA public key) per RFC 7517.
type JWKS ¶
type JWKS struct {
Keys []JWK `json:"keys"`
}
JWKS is a JSON Web Key Set, the document served at /.well-known/jwks.json.
type SIWEVerifier ¶
type SIWEVerifier struct {
// contains filtered or unexported fields
}
SIWEVerifier validates EIP-4361 login messages against the server's expected domain, uri, and chain id, and recovers the signer. It does not track nonces: it returns the message's nonce so the caller can enforce single use against its own store, keeping this a stateless primitive.
func NewSIWEVerifier ¶
func NewSIWEVerifier(domain, uri string, chainID int) *SIWEVerifier
NewSIWEVerifier binds a verifier to the expected domain/uri/chain.
func (*SIWEVerifier) Verify ¶
func (v *SIWEVerifier) Verify(rawMessage, signature string) (addr common.Address, nonce string, err error)
Verify parses and validates a SIWE message and its signature. On success it returns the recovered checksummed EVM address and the message's nonce; the caller is responsible for enforcing nonce single use. It performs no state mutation, so a failed verification leaves any nonce untouched.
type TokenValidator ¶
TokenValidator verifies a bearer token and returns its claims. Satisfied by Validator.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator verifies RS256 JWTs. Keys come either from a single in-process public key (NewValidatorWithKey) or from a remote JWKS endpoint fetched on demand and cached by key id (NewValidator).
func NewValidator ¶
NewValidator creates a Validator that fetches signing keys from a JWKS endpoint. If the issuer is non-empty, tokens must carry a matching "iss" claim.
func NewValidatorWithKey ¶
NewValidatorWithKey creates a Validator that trusts a single in-process RSA public key, keyed by kid, and performs no network fetch. The token issuer's own process uses this to validate the tokens it mints; external services validate the same tokens via the published JWKS URL using NewValidator.
func (*Validator) IsConfigured ¶
IsConfigured reports whether the validator can obtain keys (in-process or JWKS).