login

package
v0.0.0-...-e9de818 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package login implements all login management interfaces.

Index

Constants

View Source
const LoginSessionTimeoutMin = 120

Variables

View Source
var (
	UserTable map[string]*User
	UserLock  sync.RWMutex
)

权限等级 0-->admin; 1-->高级用户(agent读写+hub读写); 2-->agent读写;3-->agent只读;4-->hub读写;5-->hub只读

Functions

func GetLoginSessionTimeoutMinute

func GetLoginSessionTimeoutMinute() int64

GetLoginSessionTimeoutMinute returns the login session idle timeout time in minutes.

func Init

func Init()

Types

type User

type User struct {
	Username           string       `json:"username" bson:"username"`
	Password           string       `json:"password" bson:"password"`
	Salt               string       `json:"salt" bson:"salt"`
	Avatar             string       `json:"avatar" bson:"avatar"`
	Level              int          `json:"level" bson:"level"` // 权限等级 0-->admin; 1-->高级用户(agent读写+hub读写); 2-->agent读写;3-->agent只读;4-->hub读写;5-->hub只读
	Config             []UserConfig `json:"config" bson:"config"`
	Xml                bool         `json:"xml" bson:"xml"`
	PasswordUpdateTime int64        `json:"password_update_time" bson:"password_update_time"`
}

func GetUser

func GetUser(userName string) *User

GetUser find the user in the cache and returns, if user not exist, return nil. This interface is high-performance, but may not be up-to-date.

func GetUserFromDB

func GetUserFromDB(userName string) (*User, error)

GetUserFromDB find the user in db and returns, if user not exist, return nil.

type UserConfig

type UserConfig struct {
	Workspace string              `json:"workspace" bson:"workspace"`
	Favor     map[string][]string `json:"favor" bson:"favor"`
}

Jump to

Keyboard shortcuts

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