jwt

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Issuer is the name of the issuer for PipeCD token.
	Issuer = "PipeCD"
	// SignedTokenKey is the name of singed token key in cookie.
	SignedTokenKey = "token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	jwtgo.StandardClaims
	AvatarURL string     `json:"avatarUrl,omitempty"`
	Role      model.Role `json:"role,omitempty"`
}

Claims extends the StandardClaims with the role to access PipeCD resources.

func NewClaims

func NewClaims(githubUserID, avatarURL string, ttl time.Duration, role model.Role) *Claims

NewClaims creates a new claims for a given github user.

type Signer

type Signer interface {
	Sign(claims *Claims) (string, error)
}

func NewSigner

func NewSigner(method jwtgo.SigningMethod, keyFile string) (Signer, error)

NewSigner returns a new signer using SigningMethodRS256.

type Verifier

type Verifier interface {
	Verify(token string) (*Claims, error)
}

func NewVerifier

func NewVerifier(method jwtgo.SigningMethod, keyFile string) (Verifier, error)

NewVerifier returns a new verifier using given signing method.

Directories

Path Synopsis
Package jwttest is a generated GoMock package.
Package jwttest is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL