Documentation ¶
Index ¶
- Constants
- Variables
- func AddToken(token *Token)
- func ForbiddenError() *common.Error
- func HashUserPassword(password string) string
- func RemoveToken(token string)
- func SyncTokens(tokens []Token)
- func TokenExpiredError() *common.Error
- func UserAlreadyRegisteredError() *common.Error
- func UserNotRegisteredError() *common.Error
- func UserUnauthorizedError() *common.Error
- type Param
- type Permission
- type Rights
- type Role
- type Session
- type Token
- type User
Constants ¶
View Source
const DEFUALT_TOKEN_EXPIRATION_DATE = 60 * 60 * 24 * 365
Variables ¶
View Source
var ( TokenCollection = "tokens" Tokens = make(map[string]Token) )
View Source
var (
RoleCollection = "roles"
)
View Source
var UserCollection = "users"
Functions ¶
func ForbiddenError ¶
func HashUserPassword ¶
func RemoveToken ¶
func RemoveToken(token string)
func SyncTokens ¶
func SyncTokens(tokens []Token)
func TokenExpiredError ¶
func UserNotRegisteredError ¶
func UserUnauthorizedError ¶
Types ¶
type Permission ¶
type Role ¶
type Role struct { ID string `json:"_id" bson:"-"` Name string `json:"name" bson:"name"` Permissions map[string]Permission `json:"permissions" bson:"permissions"` }
func CreateNewRole ¶
func CreateNewRole() *Role
type Session ¶
type Session struct { ID string User User Token Token RoutePermissions Permission }
func CreateSession ¶
func CreateSession() *Session
type Token ¶
type Token struct { ID string `json:"_id" bson:"-"` Token string `json:"token" bson:"token"` EXPIRATION_TIME string `json:"expiration_time" bson:"expiration_time"` UserID string `json:"user_id" bson:"user_id"` Permissions map[string]Permission `json:"permissions" bson:"permissions"` }
func CreateNewToken ¶
func CreateNewToken() *Token
func CreateUserToken ¶
func (*Token) VerifyToken ¶
type User ¶
type User struct { ID string `json:"_id" bson:"-"` Email string `json:"email" bson:"email"` IPAddr string `json:"ipaddr" bson:"ipaddr"` Password string `json:"password" bson:"password"` Data interface{} `json:"data" bson:"data"` RoleID string `json:"role_id" bson:"role_id"` }
func CreateNewUser ¶
func CreateNewUser() *User
func (*User) Can ¶
func (user *User) Can(permission Permission) bool
func (*User) SetCredentials ¶
Click to show internal directories.
Click to hide internal directories.