security

package
v0.0.0-...-bb65b11 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JwtAccessType  = "access"
	JwtRefreshType = "refresh"
)

Variables

View Source
var CookieAccessKey = "identity_auth_key"
View Source
var CookieRefreshKey = "identity_refresh_key"

Functions

func CalcRisk

func CalcRisk(user models.Account, ip, ua string) int

func DoChallenge

func DoChallenge(challenge models.AuthChallenge, factor models.AuthFactor, code string) error

func EncodeJwt

func EncodeJwt(id string, typ, sub, sed string, aud []string, exp time.Time) (string, error)

func ExchangeOauthToken

func ExchangeOauthToken(clientId, clientSecret, redirectUri, token string) (string, string, error)

func ExchangeToken

func ExchangeToken(token string) (string, string, error)

func GetToken

func GetToken(session models.AuthSession) (string, string, error)

func GrantOauthSession

func GrantOauthSession(user models.Account, client models.ThirdClient, claims, audiences []string, expired, available *time.Time, ip, ua string) (models.AuthSession, error)

func GrantSession

func GrantSession(challenge models.AuthChallenge, claims, audiences []string, expired, available *time.Time) (models.AuthSession, error)

func HashPassword

func HashPassword(raw string) string

func NewChallenge

func NewChallenge(user models.Account, factors []models.AuthFactor, ip, ua string) (models.AuthChallenge, error)

func RefreshToken

func RefreshToken(token string) (string, string, error)

func RegenSession

func RegenSession(session models.AuthSession) (models.AuthSession, error)

func SetJwtCookieSet

func SetJwtCookieSet(c *fiber.Ctx, access, refresh string)

func VerifyFactor

func VerifyFactor(factor models.AuthFactor, code string) error

func VerifyPassword

func VerifyPassword(text string, password string) bool

Types

type PayloadClaims

type PayloadClaims struct {
	jwt.RegisteredClaims

	SessionID string `json:"sed"`
	Type      string `json:"typ"`
}

func DecodeJwt

func DecodeJwt(str string) (PayloadClaims, error)

Jump to

Keyboard shortcuts

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