Documentation ¶
Index ¶
- Constants
- func CheckTokenPermissions(Need []rune, r *http.Request) (jwt.MapClaims, error)
- func CreateToken(TokenInfo TokenStrocture) (string, error)
- func ExtractToken(r *http.Request) string
- func GenerateRandomString(s int) (string, error)
- func GetIP(c *gin.Context) string
- func GetUserAgent(c *gin.Context) string
- func GetinfoToken(tokenStr string) (jwt.MapClaims, error)
- func IsImageMIME(MIME string) bool
- func OnlyCheckpermissions(Permissions string, Need []rune) bool
- func PermissionsManager()
- func TokenValid(r *http.Request) error
- func ValidationPermissions(Permissions string) bool
- func VerifyToken(r *http.Request) (*jwt.Token, error)
- type TokenStrocture
Constants ¶
View Source
const ( FileTypeGif = "image/gif" FileTypePNG = "image/png" FileTypeJPG = "image/jpeg" )
View Source
const ( WritePost = 'W' // UpdatePost = 'U' // DelatePost = 'R' // SiteConfig = 'X' // UserManagement = 'G' // BanUser = 'B' // PublishPost = 'P' // ControlOtherPost = "O" // UploadFiles = 'L' // )
Permision Const
Variables ¶
This section is empty.
Functions ¶
func CheckTokenPermissions ¶
From a Request it validates the token and the requested permissions and returns a jwt.MapClaims with the token data.
func CreateToken ¶
func CreateToken(TokenInfo TokenStrocture) (string, error)
Create a token with a user's basic data
func GenerateRandomString ¶
Generates random String Not secure for cryptographic and related implementations
func GetIP ¶
Get the ip depending on the configuration if the IpaddressByHeader configuration parameter has a value, it will be used to obtain the ip of that header
func GetUserAgent ¶
Get the user-agent and return it in EscapeString
func GetinfoToken ¶
gets the token information and returns it in the form of jwt.MapClaims.
func OnlyCheckpermissions ¶
Checks the permissions and compares them with those required to complete the task.
func PermissionsManager ¶
func PermissionsManager()
func TokenValid ¶
Only validate that the token is valid and has not expired.
func ValidationPermissions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.