Documentation
¶
Index ¶
- Constants
- Variables
- func ContainsValue[T comparable](arr []T, value T) bool
- func Decrypt(data []byte) ([]byte, error)
- func DummyPasswordHash() (string, error)
- func Encrypt(data []byte) ([]byte, error)
- func GeneratePKCEChallenge(verifier string, isHashed ...bool) (challenge string)
- func GetDeploymentURL() string
- func Hash(data []byte) (hashed [32]byte)
- func HashPassword(password string) (string, error)
- func HashPasswordContext(ctx context.Context, password string) (string, error)
- func HashS256(data []byte) (hashed [32]byte)
- func NewCookieStore() *sessions.CookieStore
- func NewCustomDecoder() *schema.Decoder
- func NewCustomEncoder() *schema.Encoder
- func NewCustomValidator() *validator.Validate
- func ParseClientIP(r *http.Request) string
- func RandomBase58String(n int, prefix ...string) (string, error)
- func RandomBytes(n int) ([]byte, error)
- func RandomDigitString(n int) (string, error)
- func SanitizeString(input string) string
- func ValidatePasswordHash(encoded string) error
- func VerifyPassword(encoded, password string) (bool, error)
- func VerifyPasswordContext(ctx context.Context, encoded, password string) (bool, error)
- type ACR
- type AMR
- type AuthMethod
- type AuthStatus
- type ClaimType
- type Display
- type EncryptedDate
- type EncryptedString
- type Epoch
- type EpochMillis
- type GrantType
- type HashedString
- type Marshalable
- type PKCEMethod
- type Prompt
- type ResponseMode
- type ResponseType
- type Result
- type Scope
- type ScopeSlice
- type SigningAlgorithm
- type SubjectType
- type TokenType
- type Validatable
- type Writable
Constants ¶
const ( COOKIE_AUTH_KEY_ENV = "COOKIE_AUTH_KEY" COOKIE_ENC_KEY_ENV = "COOKIE_ENC_KEY" ISSUER_URL_ENV = "ISSUER_URL" MASTER_KEY_ENV = "MASTER_KEY" DEFAULT_DATE_FORMAT = "2006-01-02" // Netlify-specific environment variables // https://docs.netlify.com/configure-builds/environment-variables/#deploy-urls-and-metadata // https://docs.netlify.com/configure-builds/environment-variables/#system-environment-variables CONTEXT_ENV = "CONTEXT" URL_ENV = "URL" DEPLOY_PRIME_URL_ENV = "DEPLOY_PRIME_URL" )
const ( AUTHORIZATION_CODE_TYPE TokenType = "authorization_code" ACCESS_TOKEN_TYPE TokenType = "access_token" REFRESH_TOKEN_TYPE TokenType = "refresh_token" CLIENT_CREDENTIALS_TYPE TokenType = "client_credentials" CUSTOM_TOKEN_TYPE string = "custom_token" )
const ( ACR_VALUE = "acr" AMR_VALUE = "amr" AUTH_METHOD = "auth-method" AUTH_STATUS = "auth-status" CLAIM_TYPE = "claim-type" CONTAINS_ANY = "contains-any" DATE = "date" DISPLAY = "display" GRANT_TYPE = "grant-type" HTTPS_ORIGIN = "https_origin" HTTPS_URL = "https_url" JWS = "jws" PKCE_METHOD = "pkce-method" PROMPT = "prompt" RESPONSE_MODE = "response-mode" RESPONSE_TYPE = "response-type" RESULT = "result" SCOPE = "scope" SUBJECT_TYPE = "subject-type" TIME_GT_NOW = "time-gt-now" TIME_LT_NOW = "time-lt-now" TIME_GTE_NOW = "time-gte-now" TIME_LTE_NOW = "time-lte-now" TOKEN_TYPE = "token-type" )
const (
BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
)
const MaxPasswordBytes = 1024
MaxPasswordBytes is a byte limit, not a character limit. Passwords are never trimmed, normalized, truncated, or passed through HashedString.
Variables ¶
var ( ErrInvalidPassword = errors.New("password must contain between 1 and 1024 bytes") ErrInvalidPasswordHash = errors.New("invalid or unsupported password hash") )
Functions ¶
func ContainsValue ¶
func ContainsValue[T comparable](arr []T, value T) bool
func DummyPasswordHash ¶ added in v0.2.0
DummyPasswordHash is initialized once on demand, never by a panicking init. Initialize at service startup and verify against it for unknown/passwordless users, discarding the comparison result. Never use it to authenticate a user.
func GeneratePKCEChallenge ¶
func GetDeploymentURL ¶
func GetDeploymentURL() string
GetDeploymentURL returns the deployment URL based on the CONTEXT environment variable. In production, it uses the URL environment variable. In other contexts (like deploy previews), it uses the DEPLOY_PRIME_URL variable.
func HashPassword ¶ added in v0.2.0
HashPassword encodes a random-salted Argon2id hash in PHC format.
func HashPasswordContext ¶ added in v0.2.0
HashPasswordContext permits cancellation while waiting for a KDF slot. An already-running Argon2 computation cannot be interrupted.
func NewCookieStore ¶
func NewCookieStore() *sessions.CookieStore
func NewCustomDecoder ¶
func NewCustomEncoder ¶
func NewCustomValidator ¶
func ParseClientIP ¶
func RandomBytes ¶
func RandomDigitString ¶
func SanitizeString ¶
func ValidatePasswordHash ¶ added in v0.2.0
ValidatePasswordHash checks syntax and bounded KDF costs without doing KDF work.
func VerifyPassword ¶ added in v0.2.0
Types ¶
type AuthMethod ¶
type AuthMethod string
const ( CLIENT_SECRET_BASIC AuthMethod = "client_secret_basic" CLIENT_SECRET_POST AuthMethod = "client_secret_post" CLIENT_SECRET_JWT AuthMethod = "client_secret_jwt" PRIVATE_KEY_JWT AuthMethod = "private_key_jwt" TLS_CLIENT_AUTH AuthMethod = "tls_client_auth" SELF_SIGNED_TLS_CLIENT_AUTH AuthMethod = "self_signed_tls_client_auth" AUTH_METHOD_NONE AuthMethod = "none" )
type AuthStatus ¶
type AuthStatus string
const ( APPROVED AuthStatus = "approved" PENDING AuthStatus = "pending" DENIED AuthStatus = "denied" REVOKED AuthStatus = "revoked" )
type EncryptedDate ¶
func (EncryptedDate) MarshalJSON ¶
func (e EncryptedDate) MarshalJSON() ([]byte, error)
func (*EncryptedDate) Scan ¶
func (e *EncryptedDate) Scan(value interface{}) error
func (*EncryptedDate) UnmarshalJSON ¶
func (e *EncryptedDate) UnmarshalJSON(data []byte) (err error)
type EncryptedString ¶
type EncryptedString string
func (*EncryptedString) Scan ¶
func (e *EncryptedString) Scan(value interface{}) error
type EpochMillis ¶
func (EpochMillis) MarshalJSON ¶
func (e EpochMillis) MarshalJSON() ([]byte, error)
func (*EpochMillis) Scan ¶
func (e *EpochMillis) Scan(value interface{}) error
func (*EpochMillis) UnmarshalJSON ¶
func (e *EpochMillis) UnmarshalJSON(data []byte) (err error)
type GrantType ¶
type GrantType string
const ( AUTHORIZATION_CODE GrantType = "authorization_code" IMPLICIT GrantType = "implicit" CLIENT_CREDENTIALS GrantType = "client_credentials" REFRESH_TOKEN GrantType = "refresh_token" DEVICE_CODE GrantType = "urn:ietf:params:oauth:grant-type:device_code" JWT_BEARER GrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer" CIBA GrantType = "urn:openid:params:grant-type:ciba" )
type HashedString ¶
type HashedString string
func (*HashedString) Compare ¶
func (h *HashedString) Compare(plain []byte) bool
func (*HashedString) Scan ¶
func (h *HashedString) Scan(value interface{}) error
func (HashedString) String ¶
func (h HashedString) String() string
type Marshalable ¶
type PKCEMethod ¶
type PKCEMethod string
const ( S256 PKCEMethod = "S256" PLAIN PKCEMethod = "plain" PKCE_NONE PKCEMethod = "none" )
type ResponseMode ¶
type ResponseMode string
const ( QUERY ResponseMode = "query" FRAGMENT ResponseMode = "fragment" )
type ResponseType ¶
type ResponseType string
const ( CODE ResponseType = "code" TOKEN ResponseType = "token" ID_TOKEN ResponseType = "id_token" CODE_TOKEN ResponseType = "code token" CODE_ID_TOKEN ResponseType = "code id_token" ID_TOKEN_TOKEN ResponseType = "id_token token" CODE_ID_TOKEN_TOKEN ResponseType = "code id_token token" FORM_POST ResponseType = "form_post" )
type ScopeSlice ¶
type ScopeSlice []Scope
func (ScopeSlice) MarshalJSON ¶
func (s ScopeSlice) MarshalJSON() ([]byte, error)
func (*ScopeSlice) UnmarshalJSON ¶
func (s *ScopeSlice) UnmarshalJSON(data []byte) error
type SigningAlgorithm ¶
type SigningAlgorithm string
const ( HS256 SigningAlgorithm = "HS256" HS384 SigningAlgorithm = "HS384" HS512 SigningAlgorithm = "HS512" RS256 SigningAlgorithm = "RS256" RS384 SigningAlgorithm = "RS384" RS512 SigningAlgorithm = "RS512" ES256 SigningAlgorithm = "ES256" ES384 SigningAlgorithm = "ES384" ES512 SigningAlgorithm = "ES512" PS256 SigningAlgorithm = "PS256" PS384 SigningAlgorithm = "PS384" PS512 SigningAlgorithm = "PS512" EdDSA SigningAlgorithm = "EdDSA" )
type SubjectType ¶
type SubjectType string
const ( PAIRWISE SubjectType = "pairwise" PUBLIC SubjectType = "public" )
type Validatable ¶
type Validatable interface {
Validate() error
}
type Writable ¶
type Writable interface {
Write(w http.ResponseWriter)
}