Movatterモバイル変換


[0]ホーム

URL:


jwtutils

package
v2.28.4Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2025 License:AGPL-3.0Imports:6Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

View Source
const (SigningAlgo = jose.HS512)

Variables

View Source
var ErrMissingKeyID =xerrors.New("missing key ID")

Functions

funcDecrypt

func Decrypt(ctxcontext.Context, dDecryptKeyProvider, tokenstring, claimsClaims, opts ...func(*DecryptOptions))error

Decrypt decrypts the token using the provided key. It unmarshals into the provided claims.

funcEncrypt

func Encrypt(ctxcontext.Context, eEncryptKeyProvider, claimsClaims) (string,error)

Encrypt encrypts a token and returns it as a string.

funcSign

Sign signs a token and returns it as a string.

funcVerify

func Verify(ctxcontext.Context, vVerifyKeyProvider, tokenstring, claimsClaims, opts ...func(*VerifyOptions))error

Verify verifies that a token was signed by the provided key. It unmarshals into the provided claims.

funcWithDecryptExpected

func WithDecryptExpected(expectedjwt.Expected) func(*DecryptOptions)

funcWithVerifyExpected

func WithVerifyExpected(expectedjwt.Expected) func(*VerifyOptions)

Types

typeClaims

type Claims interface {Validate(jwt.Expected)error}

Claims defines the payload for a JWT. Most callersshould embed jwt.Claims

typeDecryptKeyProvider

type DecryptKeyProvider interface {DecryptingKey(ctxcontext.Context, idstring) (key interface{}, errerror)}

typeDecryptOptions

type DecryptOptions struct {RegisteredClaimsjwt.ExpectedKeyAlgorithm               jose.KeyAlgorithmContentEncryptionAlgorithm jose.ContentEncryption}

DecryptOptions are options for decrypting a JWE.

typeEncryptKeyProvider

type EncryptKeyProvider interface {EncryptingKey(ctxcontext.Context) (idstring, key interface{}, errerror)}

typeRegisteredClaims

type RegisteredClaimsjwt.Claims

RegisteredClaims is a convenience type for embedding jwt.Claims. It should bepreferred over embedding jwt.Claims directly since it will ensure that certain fields are set.

func (RegisteredClaims)Validate

typeSigningKeyManager

type SigningKeyManager interface {SigningKeyProviderVerifyKeyProvider}

typeSigningKeyProvider

type SigningKeyProvider interface {SigningKey(ctxcontext.Context) (idstring, key interface{}, errerror)}

typeStaticKey

type StaticKey struct {IDstringKey interface{}}

StaticKey fulfills the SigningKeycache and EncryptionKeycache interfaces. Useful for testing.

func (StaticKey)Close

func (StaticKey) Close()error

func (StaticKey)DecryptingKey

func (sStaticKey) DecryptingKey(_context.Context, idstring) (interface{},error)

func (StaticKey)EncryptingKey

func (sStaticKey) EncryptingKey(_context.Context) (string, interface{},error)

func (StaticKey)SigningKey

func (sStaticKey) SigningKey(_context.Context) (string, interface{},error)

func (StaticKey)VerifyingKey

func (sStaticKey) VerifyingKey(_context.Context, idstring) (interface{},error)

typeVerifyKeyProvider

type VerifyKeyProvider interface {VerifyingKey(ctxcontext.Context, idstring) (key interface{}, errerror)}

typeVerifyOptions

type VerifyOptions struct {RegisteredClaimsjwt.ExpectedSignatureAlgorithm jose.SignatureAlgorithm}

VerifyOptions are options for verifying a JWT.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp