Documentation ¶
Index ¶
- Constants
- Variables
- func ActiveTicket(ticket models.AuthTicket) (models.AuthTicket, error)
- func ActiveTicketWithPassword(ticket models.AuthTicket, password string) (models.AuthTicket, error)
- func AddAuditRecord(operator models.Account, act, ip, ua string, metadata map[string]any)
- func AddEvent(user uint, event, target, ip, ua string)
- func AddNotifySubscriber(user models.Account, provider, id, tk, ua string) (models.NotificationSubscriber, error)
- func AddRealmMember(user models.Account, affected models.Account, target models.Realm) error
- func Authenticate(sessionId uint) (ctx models.AuthTicket, perms map[string]any, err error)
- func CacheAccount(account models.Account)
- func CacheAuthContext(sessionId uint) (models.AuthTicket, error)
- func CacheNotificationPreference(prefs models.PreferenceNotification)
- func CacheUserStatus(uid uint, status models.Status)
- func CheckAbleToDeleteAccount(user models.Account) error
- func CheckAbleToResetPassword(user models.Account) error
- func CheckCanCheckIn(user models.Account) error
- func CheckFactor(factor models.AuthFactor, code string) error
- func CheckIn(user models.Account) (models.CheckInRecord, error)
- func CheckNotificationNotifiable(account models.Account, topic string) bool
- func CheckNotificationNotifiableBatch(accounts []models.Account, topic string) []bool
- func ClearStatus(user models.Account) error
- func ComparePermNode(held any, required any) bool
- func ConfirmAccount(code string) error
- func ConfirmDeleteAccount(code string) error
- func ConfirmResetPassword(code, newPassword string) error
- func CountRealmMember(realmId uint) (int64, error)
- func CountUserFactor(userId uint) int64
- func CreateAccount(name, nick, email, password, lang string) (models.Account, error)
- func DeleteAccount(id uint) error
- func DeleteRealm(realm models.Realm) error
- func DeleteRelationship(relationship models.AccountRelationship) error
- func DetectRisk(user models.Account, ip, ua string) int
- func DoAutoDatabaseCleanup()
- func DoAutoSignoff()
- func EditRealm(realm models.Realm) (models.Realm, error)
- func EditRelationship(relationship models.AccountRelationship) (models.AccountRelationship, error)
- func EditStatus(user models.Account, status models.Status) (models.Status, error)
- func EncodeJwt(id string, typ, sub, sed string, nonce *string, aud []string, exp time.Time, ...) (string, error)
- func ExchangeOauthToken(clientId, clientSecret, redirectUri, token string) (idk, atk, rtk string, err error)
- func ExchangeToken(token string) (atk, rtk string, err error)
- func FilterPermNodes(tree map[string]any, claims []string) map[string]any
- func ForceConfirmAccount(user models.Account) error
- func GetAbuseReport(id uint) (models.AbuseReport, error)
- func GetAccount(id uint) (models.Account, error)
- func GetAccountCacheKey(query any) string
- func GetAccountList(id []uint) ([]models.Account, error)
- func GetAccountWithName(alias string) (models.Account, error)
- func GetAuthContext(sessionId uint) (models.AuthTicket, error)
- func GetAuthContextCacheKey(sessionId uint) string
- func GetAuthPreference(account models.Account) (models.PreferenceAuth, error)
- func GetBotCount(user models.Account) (int64, error)
- func GetFactor(id uint) (models.AuthFactor, error)
- func GetFactorCode(factor models.AuthFactor, ip string) (bool, error)
- func GetNotificationPreference(account models.Account) (models.PreferenceNotification, error)
- func GetNotificationPreferenceCacheKey(accountId uint) string
- func GetPasswordTypeFactor(userId uint) (models.AuthFactor, error)
- func GetRealmMember(userId uint, realmId uint) (models.RealmMember, error)
- func GetRealmWithAlias(alias string) (models.Realm, error)
- func GetRelationWithTwoNode(userId, relatedId uint, noPreload ...bool) (models.AccountRelationship, error)
- func GetRelationship(otherId uint) (models.AccountRelationship, error)
- func GetStatus(uid uint) (models.Status, error)
- func GetStatusCacheKey(uid uint) string
- func GetStatusDisturbable(uid uint) error
- func GetStatusOnline(uid uint) error
- func GetThirdClient(id string) (models.ThirdClient, error)
- func GetThirdClientWithSecret(id, secret string) (models.ThirdClient, error)
- func GetThirdClientWithUser(id string, userId uint) (models.ThirdClient, error)
- func GetTicket(id uint) (models.AuthTicket, error)
- func GetTicketWithToken(tokenId string) (models.AuthTicket, error)
- func GetTodayCheckIn(user models.Account) (models.CheckInRecord, error)
- func GetToken(ticket models.AuthTicket) (atk, rtk string, err error)
- func GetUserAccountGroup(user models.Account) ([]models.AccountGroup, error)
- func GetUserOnline(uid uint) bool
- func GrantBadge(user models.Account, badge models.Badge) error
- func HandleFriend(userA models.Account, userB models.Account, isAccept bool) error
- func HasPermNode(perms map[string]any, requiredKey string, requiredValue any) bool
- func HasPermNodeWithDefault(perms map[string]any, requiredKey string, requiredValue any, defaultValue any) bool
- func HashPassword(raw string) string
- func InvalidAuthCacheWithUser(userId uint)
- func ListAbuseReport(account models.Account) ([]models.AbuseReport, error)
- func ListAllRelationship(user models.Account) ([]models.AccountRelationship, error)
- func ListAvailableRealm(user models.Account) ([]models.Realm, error)
- func ListCommunityRealm() ([]models.Realm, error)
- func ListOwnedRealm(user models.Account) ([]models.Realm, error)
- func ListRealmMember(realmId uint, take int, offset int) ([]models.RealmMember, error)
- func ListRelationshipWithFilter(user models.Account, status ...models.RelationshipStatus) ([]models.AccountRelationship, error)
- func ListUserFactor(userId uint) ([]models.AuthFactor, error)
- func LookupAccount(probe string) (models.Account, error)
- func NewAbuseReport(resource string, reason string, account models.Account) (models.AbuseReport, error)
- func NewApiKey(user models.Account, key models.ApiKey, ip, ua string, claims []string) (models.ApiKey, error)
- func NewBlockship(userA models.Account, userB models.Account) (models.AccountRelationship, error)
- func NewBot(user models.Account, bot models.Account) (models.Account, error)
- func NewFriend(userA models.Account, userB models.Account, skipPending ...bool) (models.AccountRelationship, error)
- func NewMagicToken(mode models.MagicTokenType, assignTo *models.Account, expiredAt *time.Time) (models.MagicToken, error)
- func NewNotification(notification models.Notification) error
- func NewNotificationBatch(notifications []models.Notification) error
- func NewOauthTicket(user models.Account, client models.ThirdClient, claims, audiences []string, ...) (models.AuthTicket, error)
- func NewRealm(realm models.Realm, user models.Account) (models.Realm, error)
- func NewStatus(user models.Account, status models.Status) (models.Status, error)
- func NewTicket(user models.Account, ip, ua string) (models.AuthTicket, error)
- func NotifyMagicToken(token models.MagicToken) error
- func PerformTicketCheck(ticket models.AuthTicket, factor models.AuthFactor, code string) (models.AuthTicket, error)
- func PickTicketAttempt(user models.Account, ip string) (models.AuthTicket, error)
- func PushNotification(notification models.Notification, skipNotifiableCheck ...bool) error
- func PushNotificationBatch(notifications []models.Notification, skipNotifiableCheck ...bool)
- func RecycleUnConfirmAccount()
- func RefreshToken(token string) (atk, rtk string, err error)
- func RemoveRealmMember(user models.Account, affected models.RealmMember, target models.Realm) error
- func RequestDeleteAccount(user models.Account) error
- func RequestResetPassword(user models.Account) error
- func RevokeBadge(badge models.Badge) error
- func RollApiKey(key models.ApiKey) (models.ApiKey, error)
- func RotateTicket(ticket models.AuthTicket, fullyRestart ...bool) (models.AuthTicket, error)
- func SaveEventChanges()
- func SearchAccount(probe string) ([]models.Account, error)
- func SetAccountLastSeen(uid uint) error
- func UpdateAbuseReportStatus(id uint, status, message string) error
- func UpdateAuthPreference(account models.Account, config models.AuthConfig) (models.PreferenceAuth, error)
- func UpdateNotificationPreference(account models.Account, config map[string]bool) (models.PreferenceNotification, error)
- func ValidateAccountName(val string, min, max int) bool
- func ValidateMagicToken(code string, mode models.MagicTokenType) (models.MagicToken, error)
- func VerifyPassword(text string, password string) bool
- type PayloadClaims
Constants ¶
const ( JwtAccessType = "access" JwtRefreshType = "refresh" )
const CheckInResultModifiersLength = 4
const InternalTokenAudience = "solar-network"
Variables ¶
var EReader *sec.JwtReader
var EWriter *sec.JwtWriter
Functions ¶
func ActiveTicket ¶
func ActiveTicket(ticket models.AuthTicket) (models.AuthTicket, error)
func ActiveTicketWithPassword ¶
func ActiveTicketWithPassword(ticket models.AuthTicket, password string) (models.AuthTicket, error)
func AddAuditRecord ¶
AddAuditRecord to keep logs to make administrators' operations clear to query
func AddNotifySubscriber ¶
func AddRealmMember ¶
func Authenticate ¶
func CacheAccount ¶
func CacheAuthContext ¶
func CacheAuthContext(sessionId uint) (models.AuthTicket, error)
func CacheNotificationPreference ¶
func CacheNotificationPreference(prefs models.PreferenceNotification)
func CacheUserStatus ¶
func CheckCanCheckIn ¶
func CheckFactor ¶
func CheckFactor(factor models.AuthFactor, code string) error
func ClearStatus ¶
func ComparePermNode ¶
func ConfirmAccount ¶
func ConfirmDeleteAccount ¶
func ConfirmResetPassword ¶
func CountRealmMember ¶
func CountUserFactor ¶
func CreateAccount ¶
func DeleteAccount ¶
func DeleteRealm ¶
func DeleteRelationship ¶
func DeleteRelationship(relationship models.AccountRelationship) error
func DetectRisk ¶
DetectRisk is used for detect user environment is suitable for no multifactorial authenticating or not. Return the remaining steps, value is from 1 to 2, may appear 3 if user enabled the third-authentication-factor.
func DoAutoDatabaseCleanup ¶
func DoAutoDatabaseCleanup()
func DoAutoSignoff ¶
func DoAutoSignoff()
func EditRelationship ¶
func EditRelationship(relationship models.AccountRelationship) (models.AccountRelationship, error)
func ExchangeOauthToken ¶
func ExchangeToken ¶
func ForceConfirmAccount ¶
func GetAbuseReport ¶
func GetAbuseReport(id uint) (models.AbuseReport, error)
func GetAccountCacheKey ¶
func GetAuthContext ¶
func GetAuthContext(sessionId uint) (models.AuthTicket, error)
func GetAuthContextCacheKey ¶
func GetAuthPreference ¶
func GetAuthPreference(account models.Account) (models.PreferenceAuth, error)
func GetFactorCode ¶
func GetFactorCode(factor models.AuthFactor, ip string) (bool, error)
func GetNotificationPreference ¶
func GetNotificationPreference(account models.Account) (models.PreferenceNotification, error)
func GetPasswordTypeFactor ¶
func GetPasswordTypeFactor(userId uint) (models.AuthFactor, error)
func GetRealmMember ¶
func GetRealmMember(userId uint, realmId uint) (models.RealmMember, error)
func GetRelationWithTwoNode ¶
func GetRelationWithTwoNode(userId, relatedId uint, noPreload ...bool) (models.AccountRelationship, error)
func GetRelationship ¶
func GetRelationship(otherId uint) (models.AccountRelationship, error)
func GetStatusCacheKey ¶
func GetStatusDisturbable ¶
func GetStatusOnline ¶
func GetThirdClient ¶
func GetThirdClient(id string) (models.ThirdClient, error)
func GetThirdClientWithSecret ¶
func GetThirdClientWithSecret(id, secret string) (models.ThirdClient, error)
func GetThirdClientWithUser ¶
func GetThirdClientWithUser(id string, userId uint) (models.ThirdClient, error)
func GetTicketWithToken ¶
func GetTicketWithToken(tokenId string) (models.AuthTicket, error)
func GetTodayCheckIn ¶
func GetTodayCheckIn(user models.Account) (models.CheckInRecord, error)
func GetUserAccountGroup ¶
func GetUserAccountGroup(user models.Account) ([]models.AccountGroup, error)
func GetUserOnline ¶
func HandleFriend ¶
func HasPermNode ¶
func HasPermNodeWithDefault ¶
func HashPassword ¶
func InvalidAuthCacheWithUser ¶
func InvalidAuthCacheWithUser(userId uint)
func ListAbuseReport ¶
func ListAbuseReport(account models.Account) ([]models.AbuseReport, error)
func ListAllRelationship ¶
func ListAllRelationship(user models.Account) ([]models.AccountRelationship, error)
func ListCommunityRealm ¶
func ListRealmMember ¶
func ListRelationshipWithFilter ¶
func ListRelationshipWithFilter(user models.Account, status ...models.RelationshipStatus) ([]models.AccountRelationship, error)
func ListUserFactor ¶
func ListUserFactor(userId uint) ([]models.AuthFactor, error)
func NewAbuseReport ¶
func NewBlockship ¶
func NewMagicToken ¶
func NewMagicToken(mode models.MagicTokenType, assignTo *models.Account, expiredAt *time.Time) (models.MagicToken, error)
func NewNotification ¶
func NewNotification(notification models.Notification) error
NewNotification will create a notification and push via the push method it Pleases provide the notification with the account field is not empty
func NewNotificationBatch ¶
func NewNotificationBatch(notifications []models.Notification) error
func NewOauthTicket ¶
func NewOauthTicket( user models.Account, client models.ThirdClient, claims, audiences []string, ip, ua string, nonce *string, ) (models.AuthTicket, error)
func NotifyMagicToken ¶
func NotifyMagicToken(token models.MagicToken) error
func PerformTicketCheck ¶
func PerformTicketCheck(ticket models.AuthTicket, factor models.AuthFactor, code string) (models.AuthTicket, error)
func PickTicketAttempt ¶
PickTicketAttempt is trying to pick up the ticket that hasn't completed but created by a same client (identify by ip address). Then the client can continue their journey to get ticket activated.
func PushNotification ¶
func PushNotification(notification models.Notification, skipNotifiableCheck ...bool) error
PushNotification will push a notification to the user, via websocket, firebase, or APNs Please provide the notification with the account field is not empty
func PushNotificationBatch ¶
func PushNotificationBatch(notifications []models.Notification, skipNotifiableCheck ...bool)
PushNotificationBatch will push a notification to the user The notification should be the same for all users except the account id field For the notification push, the method will only use the first notification as template
func RecycleUnConfirmAccount ¶
func RecycleUnConfirmAccount()
func RefreshToken ¶
func RemoveRealmMember ¶
func RequestDeleteAccount ¶
func RequestResetPassword ¶
func RevokeBadge ¶
func RotateTicket ¶
func RotateTicket(ticket models.AuthTicket, fullyRestart ...bool) (models.AuthTicket, error)
func SaveEventChanges ¶
func SaveEventChanges()
SaveEventChanges runs every 60 seconds to save events / audits changes into the database
func SetAccountLastSeen ¶
func UpdateAbuseReportStatus ¶
func UpdateAuthPreference ¶
func UpdateAuthPreference(account models.Account, config models.AuthConfig) (models.PreferenceAuth, error)
func ValidateAccountName ¶
func ValidateMagicToken ¶
func ValidateMagicToken(code string, mode models.MagicTokenType) (models.MagicToken, error)
func VerifyPassword ¶
Types ¶
type PayloadClaims ¶
type PayloadClaims struct { jwt.RegisteredClaims // Internal Stuff SessionID string `json:"sed"` // ID Token Stuff Name string `json:"name,omitempty"` Nick string `json:"preferred_username,omitempty"` Email string `json:"email,omitempty"` // Additional Stuff AuthorizedParties string `json:"azp,omitempty"` Nonce string `json:"nonce,omitempty"` Type string `json:"typ"` }