auth

package
v0.0.0-...-6f95374 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultExpiresInSecond = 3600 // 1 hour (60s * 60m)
	DefaultExpiresIn       = ExpiresIn(DefaultExpiresInSecond)
)
View Source
const AuthTokenKey = "auth-token"
View Source
const SessionTokenKey = "session-token"

Variables

This section is empty.

Functions

func DecodePublicKey

func DecodePublicKey(value string) (rsa.PublicKey, error)

Types

type AuthToken

type AuthToken string //nolint:revive

func GenerateAuthToken

func GenerateAuthToken(
	userID user.ID,
	secret Secret,
	expiresIn ExpiresIn,
) AuthToken

func ParseAuthToken

func ParseAuthToken(
	token string,
	secret Secret,
) (AuthToken, error)

func (AuthToken) String

func (at AuthToken) String() string

func (AuthToken) UserID

func (at AuthToken) UserID() user.ID

type CodeID

type CodeID uuid.UUID

func GenerateCodeID

func GenerateCodeID() CodeID

GenerateCodeID CodeIDを新規に発行する関数.

func NewCodeID

func NewCodeID(value string) (CodeID, error)

NewCodeID CodeIDを作成するファクトリー関数.

func (CodeID) String

func (cd CodeID) String() string

String CodeIDを文字列型として提供するメソッド.

func (CodeID) Value

func (cd CodeID) Value() uuid.UUID

Value CodeIDをuuid.UUID型として提供するメソッド.

func (CodeID) Verify

func (cd CodeID) Verify(
	signature Signature,
	publicKey *rsa.PublicKey,
) error

type Email

type Email string

func NewEmail

func NewEmail(value string) (Email, error)

func (Email) String

func (em Email) String() string

type ExpiresIn

type ExpiresIn int

func NewExpiresIn

func NewExpiresIn(value int) (ExpiresIn, error)

func (ExpiresIn) Duration

func (ei ExpiresIn) Duration() time.Duration

func (ExpiresIn) Int

func (ei ExpiresIn) Int() int

type InvitationCode

type InvitationCode string

func GenerateInvitationCode

func GenerateInvitationCode() InvitationCode

func NewInvitationCode

func NewInvitationCode(value string) (InvitationCode, error)

func (InvitationCode) String

func (ic InvitationCode) String() string

type Password

type Password string

func NewPassword

func NewPassword(value string) (Password, error)

func (Password) Equal

func (pw Password) Equal(password Password) bool

func (Password) String

func (pw Password) String() string

type Secret

type Secret string

func (Secret) String

func (s Secret) String() string

type SessionID

type SessionID uuid.UUID

func GenerateSessionID

func GenerateSessionID() SessionID

GenerateSessionID SessionIDを新規に発行する関数.

func NewSessionID

func NewSessionID(value string) (SessionID, error)

NewSessionID SessionIDを作成するファクトリー関数.

func (SessionID) String

func (sid SessionID) String() string

String SessionIDを文字列型として提供するメソッド.

func (SessionID) ToSecret

func (sid SessionID) ToSecret() Secret

ToSecret SessionIDをSecret型として提供するメソッド.

func (SessionID) Value

func (sid SessionID) Value() uuid.UUID

Value SessionIDをuuid.UUID型として提供するメソッド.

type SessionToken

type SessionToken string

func GenerateSessionToken

func GenerateSessionToken(
	sessionID SessionID,
	secret Secret,
) SessionToken

func ParseSessionToken

func ParseSessionToken(
	token string,
	secret Secret,
) (SessionToken, error)

func (SessionToken) ID

func (st SessionToken) ID(secret Secret) SessionID

func (SessionToken) String

func (st SessionToken) String() string

func (SessionToken) ToSecret

func (st SessionToken) ToSecret(secret Secret) Secret

type Signature

type Signature string

func NewSignature

func NewSignature(value string) (Signature, error)

func (Signature) String

func (sig Signature) String() string

Jump to

Keyboard shortcuts

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