Documentation ¶
Index ¶
- Constants
- func Authenticate(c *gin.Context, db *gorm.DB, minimumAuthState int, chainUID string) (ok bool, authUser *models.User, chain *models.Chain)
- func AuthenticateEvent(c *gin.Context, db *gorm.DB, eventUID string) (ok bool, authUser *models.User, event *models.Event)
- func AuthenticateToken(db *gorm.DB, tokenString string) (*models.User, bool, error)
- func AuthenticateUserOfChain(c *gin.Context, db *gorm.DB, chainUID, userUID string) (ok bool, user, authUser *models.User, chain *models.Chain)
- func CookieRemove(c *gin.Context)
- func CookieSet(c *gin.Context, userUID, token string)
- func JwtGenerate(user *models.User) (string, error)
- func OtpCreate(db *gorm.DB, userID uint) (string, error)
- func OtpDeleteOld(db *gorm.DB)
- func OtpVerify(db *gorm.DB, userEmail, otp string) (*models.User, string, error)
- func TokenReadFromRequest(c *gin.Context) (string, bool)
- type MyJwtClaims
Constants ¶
View Source
const ( AuthState0Guest = 0 AuthState1AnyUser = 1 AuthState2UserOfChain = 2 AuthState3AdminChainUser = 3 AuthState4RootUser = 4 )
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
func Authenticate(c *gin.Context, db *gorm.DB, minimumAuthState int, chainUID string) (ok bool, authUser *models.User, chain *models.Chain)
There are 4 different states to authenticate 0. Guest - this middleware is then not required 1. User of a different/unknown chain 2. User connected to the chain in question 3. Admin User of the chain in question 4. Root User
func AuthenticateEvent ¶
func AuthenticateToken ¶
func AuthenticateUserOfChain ¶
func AuthenticateUserOfChain(c *gin.Context, db *gorm.DB, chainUID, userUID string) (ok bool, user, authUser *models.User, chain *models.Chain)
This runs Authenticate and defines minimumAuthState depending on the input Any of the following rules pass authentication
1. authUser UID is the same as the given userUID 2. authUser is a chain admin of chain and user is part that same chain 3. authUser is a root admin
func CookieRemove ¶
func OtpDeleteOld ¶
Types ¶
type MyJwtClaims ¶
type MyJwtClaims struct { jwt.RegisteredClaims Pepper int `json:"pepper"` }
Click to show internal directories.
Click to hide internal directories.