token

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractUserID

func ExtractUserID(subject string) (string, error)

Types

type IDToken

type IDToken struct {
	Issuer   string    `json:"iss"`
	Subject  string    `json:"sub"`
	Audience string    `json:"aud"`
	Expiry   time.Time `json:"exp"`
	IssuedAt time.Time `json:"iat"`
	Email    string    `json:"email"`
	// Use "role" as json tag to keep compatibility.
	// AdminRole is accountproto.Account_OWNER in the case of AdminAccount.
	// AdminRole is accountproto.Account_UNASSIGNED in the case of Account.
	AdminRole accountproto.Account_Role `json:"role"`
}

func (*IDToken) IsAdmin

func (t *IDToken) IsAdmin() bool

type Signer

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

func NewSigner

func NewSigner(keyPath string) (Signer, error)

func NewSignerWithPrivateKey

func NewSignerWithPrivateKey(privateKey *rsa.PrivateKey) (Signer, error)

type Verifier

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

func NewVerifier

func NewVerifier(keyPath, issuer, clientID string) (Verifier, error)

Jump to

Keyboard shortcuts

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