iamapi

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Role_Sysadmin  = "sa"
	Role_User      = "user"
	Role_Guest     = "guest"
	Role_Developer = "dev"
)
View Source
const (
	UserSysadmin    = "sysadmin"
	DefaultPassword = "changeme"
)
View Source
const (
	UserKeyDefault = "std"

	UserTypeGroup = "group"
)

Variables

View Source
var (
	ErrCodeAccessDenied    = "AccessDenied"
	ErrCodeUnauthorized    = "Unauthorized" // Need to login and fetch a new access-token
	ErrCodeInvalidArgument = "InvalidArgument"
	ErrCodeUnavailable     = "Unavailable"
	ErrCodeServerError     = "ServerError"
	ErrCodeInternalError   = "InternalError"
	ErrCodeNotFound        = "NotFound"
)

Functions

func NsAccessKey

func NsAccessKey(uname, id string) []byte

func NsAppInstance

func NsAppInstance(id string) []byte

func NsAuthCode

func NsAuthCode(code string) []byte

func NsMsgQueue

func NsMsgQueue(id string) []byte

func NsMsgSent

func NsMsgSent(id string) []byte

func NsRole

func NsRole(name string) []byte

func NsRolePrivilege

func NsRolePrivilege(role, appid string) []byte

func NsSysConfig

func NsSysConfig(name string) []byte

func NsUser

func NsUser(uname string) []byte

func NsUserAuthDeny

func NsUserAuthDeny(uname, remoteIp string) []byte

func NsUserProfile

func NsUserProfile(uname string) []byte

func NsUserResetPassword

func NsUserResetPassword(id string) []byte

func NsUserSession

func NsUserSession(uname string, created uint32) []byte

func ServiceRedirectTokenValid

func ServiceRedirectTokenValid(tokenstr string) bool

func UserNameFilter

func UserNameFilter(name string) string

Types

type AppInstance

type AppInstance struct {
	ID          string           `json:"id,omitempty" toml:"id,omitempty"`
	Name        string           `json:"name" toml:"name"`
	User        string           `json:"user,omitempty" toml:"user,omitempty"`
	Version     string           `json:"version,omitempty" toml:"version,omitempty"`
	Status      uint8            `json:"status,omitempty" toml:"status,omitempty"`
	Url         string           `json:"url,omitempty" toml:"url,omitempty"`
	Permissions []*AppPermission `json:"permissions,omitempty" toml:"permissions,omitempty"`
	SecretKey   string           `json:"secret_key,omitempty" toml:"secret_key,omitempty"`
	Created     int64            `json:"created,omitempty" toml:"created,omitempty"`
	Updated     int64            `json:"updated,omitempty" toml:"updated,omitempty"`
}

type AppPermission

type AppPermission struct {
	Permission string   `json:"permission" toml:"permission"`
	Roles      []string `json:"roles,omitempty" toml:"roles,omitempty"`
	Summary    string   `json:"summary,omitempty" toml:"summary,omitempty"`
}

type ServiceRedirectToken

type ServiceRedirectToken struct {
	RedirectUri string `json:"uri,omitempty" toml:"uri,omitempty"`
	State       string `json:"state,omitempty" toml:"state,omitempty"`
	ClientId    string `json:"cid,omitempty" toml:"cid,omitempty"`
	Persistent  int    `json:"pt,omitempty" toml:"pt,omitempty"`
}

func ServiceRedirectTokenDecode

func ServiceRedirectTokenDecode(tokenstr string) ServiceRedirectToken

func (*ServiceRedirectToken) Encode

func (s *ServiceRedirectToken) Encode() string

type SignInAuthCode

type SignInAuthCode struct {
	AccessToken string `json:"access_token"`
	Username    string `json:"username"`
}

type SysConfigMailer

type SysConfigMailer struct {
	SmtpHost string `json:"smtp_host" toml:"smtp_host"`
	SmtpPort string `json:"smtp_port" toml:"smtp_port"`
	SmtpUser string `json:"smtp_user" toml:"smtp_user"`
	SmtpPass string `json:"smtp_pass" toml:"smtp_pass"`
}

type User

type User struct {
	Name        string        `json:"name" toml:"name"`
	Email       string        `json:"email,omitempty" toml:"email,omitempty"`
	DisplayName string        `json:"display_name,omitempty" toml:"display_name,omitempty"`
	Keys        types.KvPairs `json:"keys,omitempty" toml:"keys,omitempty"`
	Roles       []string      `json:"roles,omitempty" toml:"roles,omitempty"`
	Type        string        `json:"type,omitempty" toml:"type,omitempty"`
	Owners      []string      `json:"owners,omitempty" toml:"owners,omitempty"`
	Members     []string      `json:"members,omitempty" toml:"members,omitempty"`
	Status      uint8         `json:"status,omitempty" toml:"status,omitempty"`
	Created     int64         `json:"created,omitempty" toml:"created,omitempty"`
	Updated     int64         `json:"updated,omitempty" toml:"updated,omitempty"`
}

type UserProfile

type UserProfile struct {
	Login       *User  `json:"login,omitempty" toml:"login,omitempty"`
	DisplayName string `json:"display_name,omitempty" toml:"display_name,omitempty"`
	Email       string `json:"email,omitempty" toml:"email,omitempty"`
	Gender      uint8  `json:"gender,omitempty" toml:"gender,omitempty"`
	Birthday    string `json:"birthday,omitempty" toml:"birthday,omitempty"`
	About       string `json:"about,omitempty" toml:"about,omitempty"`
	Photo       string `json:"photo,omitempty" toml:"photo,omitempty"`
	PhotoSource string `json:"photo_source,omitempty" toml:"photo_source,omitempty"`
	Updated     int64  `json:"updated,omitempty" toml:"updated,omitempty"`
}

type UserResetPassword

type UserResetPassword struct {
	Id       string `json:"id"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Expired  int64  `json:"expired"`
}

type UserRole

type UserRole struct {
	Name        string   `json:"name" toml:"name"`
	User        string   `json:"user,omitempty" toml:"user,omitempty"`
	Status      uint8    `json:"status,omitempty" toml:"status,omitempty"`
	Desc        string   `json:"desc,omitempty" toml:"desc,omitempty"`
	Permissions []string `json:"permissions,omitempty" toml:"permissions,omitempty"`
	Created     int64    `json:"created,omitempty" toml:"created,omitempty"`
	Updated     int64    `json:"updated,omitempty" toml:"updated,omitempty"`
}

type Validator

type Validator func(string) error
var (
	UsernameValid Validator

	RoleValid Validator

	AppIdValid Validator

	ObjectIdValid = regexp.MustCompile("^[0-9a-f]{12,16}$")

	EmailValid Validator

	// RFC 1123 DNS label
	DNSLabelValid Validator
)

Jump to

Keyboard shortcuts

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