services

package
v0.0.0-...-35f9580 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JwtAccessType  = "access"
	JwtRefreshType = "refresh"
)
View Source
const ConfirmRegistrationTemplate = `` /* 600-byte string literal not displayed */
View Source
const EmailPasswordTemplate = `` /* 534-byte string literal not displayed */

Variables

View Source
var CookieAccessKey = "passport_auth_key"
View Source
var CookieRefreshKey = "passport_refresh_key"
View Source
var WsConn = make(map[uint][]*websocket.Conn)

Functions

func ActiveTicketWithMFA

func ActiveTicketWithMFA(ticket models.AuthTicket, factor models.AuthFactor, code string) (models.AuthTicket, error)

func ActiveTicketWithPassword

func ActiveTicketWithPassword(ticket models.AuthTicket, password string) (models.AuthTicket, error)

func AddEvent

func AddEvent(user models.Account, event, target, ip, ua string) models.ActionEvent

func AddNotifySubscriber

func AddNotifySubscriber(user models.Account, provider, device, ua string) (models.NotificationSubscriber, error)

func AddRealmMember

func AddRealmMember(user models.Account, affected models.Account, target models.Realm) error

func Authenticate

func Authenticate(access, refresh string, depth int) (user models.Account, newAccess, newRefresh string, err error)

func CheckFactor

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

func CheckOnline

func CheckOnline(user models.Account) bool

func ConfirmAccount

func ConfirmAccount(code string) error

func CountUserFactor

func CountUserFactor(userId uint) int64

func CreateAccount

func CreateAccount(name, nick, email, password string) (models.Account, error)

func DeleteFriend

func DeleteFriend(relationship models.AccountFriendship) error

func DeleteRealm

func DeleteRealm(realm models.Realm) error

func DetectRisk

func DetectRisk(user models.Account, ip, ua string) bool

func DoAutoAuthCleanup

func DoAutoAuthCleanup()

func DoAutoDatabaseCleanup

func DoAutoDatabaseCleanup()

func DoAutoSignoff

func DoAutoSignoff()

func EditFriend

func EditFriend(relationship models.AccountFriendship) (models.AccountFriendship, error)

func EditFriendWithCheck

func EditFriendWithCheck(relationship models.AccountFriendship, user models.Account, originalStatus models.FriendshipStatus) (models.AccountFriendship, error)

func EditRealm

func EditRealm(realm models.Realm) (models.Realm, 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 GetAccount

func GetAccount(id uint) (models.Account, error)

func GetAuthContext

func GetAuthContext(jti string) (models.AuthContext, error)

func GetFactor

func GetFactor(id uint) (models.AuthFactor, error)

func GetFactorCode

func GetFactorCode(factor models.AuthFactor) (bool, error)

func GetFactorName

func GetFactorName(w models.AuthFactorType, localizer *i18n.Localizer) string

func GetFriend

func GetFriend(anysideId uint) (models.AccountFriendship, error)

func GetFriendWithTwoSides

func GetFriendWithTwoSides(userId, relatedId uint, noPreload ...bool) (models.AccountFriendship, error)

func GetPasswordTypeFactor

func GetPasswordTypeFactor(userId uint) (models.AuthFactor, error)

func GetRealmMember

func GetRealmMember(userId uint, realmId uint) (models.RealmMember, error)

func GetRealmWithAlias

func GetRealmWithAlias(alias string) (models.Realm, error)

func GetThirdClient

func GetThirdClient(id string) (models.ThirdClient, error)

func GetThirdClientWithSecret

func GetThirdClientWithSecret(id, secret string) (models.ThirdClient, error)

func GetTicket

func GetTicket(id uint) (models.AuthTicket, error)

func GetTicketWithToken

func GetTicketWithToken(tokenId string) (models.AuthTicket, error)

func GetToken

func GetToken(ticket models.AuthTicket) (string, string, error)

func GrantAuthContext

func GrantAuthContext(jti string) (models.AuthContext, error)

func HashPassword

func HashPassword(raw string) string

func ListAllFriend

func ListAllFriend(anyside models.Account) ([]models.AccountFriendship, error)

func ListAvailableRealm

func ListAvailableRealm(user models.Account) ([]models.Realm, error)

func ListCommunityRealm

func ListCommunityRealm() ([]models.Realm, error)

func ListFriend

func ListFriend(anyside models.Account, status models.FriendshipStatus) ([]models.AccountFriendship, error)

func ListOwnedRealm

func ListOwnedRealm(user models.Account) ([]models.Realm, error)

func ListRealmMember

func ListRealmMember(realmId uint) ([]models.RealmMember, error)

func ListUserFactor

func ListUserFactor(userId uint) ([]models.AuthFactor, error)

func LookupAccount

func LookupAccount(probe string) (models.Account, error)

func NewFriend

func NewFriend(user models.Account, related models.Account, status models.FriendshipStatus) (models.AccountFriendship, error)

func NewMagicToken

func NewMagicToken(mode models.MagicTokenType, assignTo *models.Account, expiredAt *time.Time) (models.MagicToken, error)

func NewNotification

func NewNotification(notification models.Notification) error

func NewOauthTicket

func NewOauthTicket(
	user models.Account,
	client models.ThirdClient,
	claims, audiences []string,
	ip, ua string,
) (models.AuthTicket, error)

func NewRealm

func NewRealm(realm models.Realm, user models.Account) (models.Realm, error)

func NewTicket

func NewTicket(user models.Account, ip, ua string) (models.AuthTicket, error)

func NotifyMagicToken

func NotifyMagicToken(token models.MagicToken) error

func PushNotification

func PushNotification(notification models.Notification) error

func RefreshToken

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

func RegenSession

func RegenSession(ticket models.AuthTicket) (models.AuthTicket, error)

func RemoveRealmMember

func RemoveRealmMember(user models.Account, affected models.Account, target models.Realm) error

func RevokeAuthContext

func RevokeAuthContext(jti string) error

func SendMail

func SendMail(target string, subject string, content string) error

func SendMailHTML

func SendMailHTML(target string, subject string, content string) error

func SetJwtCookieSet

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

func ValidateMagicToken

func ValidateMagicToken(code string, mode models.MagicTokenType) (models.MagicToken, 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)

type WsPushRequest

type WsPushRequest struct {
	Payload     []byte
	RecipientID uint
}

Jump to

Keyboard shortcuts

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