Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayFromJson(data io.Reader) []string
- func ArrayToJson(objmap []string) string
- func ComparePassword(hash string, password string) bool
- func Etag(parts ...interface{}) string
- func GetAllTasks() *map[string]*ScheduledTask
- func GetMillis() int64
- func GetPreviousVersion(version string) string
- func HashPassword(password string) string
- func InitalizePermissions()
- func InitalizeRoles()
- func IsCurrentVersion(versionToCheck string) bool
- func IsOfficalBuild() bool
- func IsPreviousVersionsSupported(versionToCheck string) bool
- func IsValidHttpUrl(rawUrl string) bool
- func IsValidUserRoles(userRoles string) bool
- func IsValidUsername(s string) bool
- func MapFromJson(data io.Reader) map[string]string
- func MapToJson(objmap map[string]string) string
- func NewId() string
- func NewRandomString(length int) string
- func OAuthAppListToJson(l []*OAuthApp) string
- func OAuthAppMapFromJson(data io.Reader) map[string]*OAuthApp
- func OAuthAppMapToJson(a map[string]*OAuthApp) string
- func RoleIdsToString(roles []string) string
- func SplitVersion(version string) (int64, int64, int64)
- func StringInterfaceToJson(objmap map[string]interface{}) string
- func UserListToJson(u []*User) string
- type ALiYunCommunicationRequest
- func (req *ALiYunCommunicationRequest) BuildSmsRequestEndpoint(accessKeySecret, gatewayUrl string) (string, error)
- func (req *ALiYunCommunicationRequest) SetParamsValue(accessKeyId, phoneNumbers, signName, templateCode, templateParam string) error
- func (req *ALiYunCommunicationRequest) SmsParamsIsValid() error
- type AccessData
- type AccessResponse
- type AppError
- func AppErrorFromJson(data io.Reader) *AppError
- func InvalidUserError(fieldName string, userId string) *AppError
- func NewAppError(where string, id string, params map[string]interface{}, details string, ...) *AppError
- func NewLocAppError(where string, id string, params map[string]interface{}, details string) *AppError
- type Client
- func (c *Client) ClearOAuthToken()
- func (c *Client) CreateUser(user *User) (*User, *Response)
- func (c *Client) DoApiDelete(url string) (*http.Response, *AppError)
- func (c *Client) DoApiGet(url string, etag string) (*http.Response, *AppError)
- func (c *Client) DoApiPost(url string, data string) (*http.Response, *AppError)
- func (c *Client) DoApiPut(url string, data string) (*http.Response, *AppError)
- func (c *Client) DoApiRequest(method, url, data, etag string) (*http.Response, *AppError)
- func (c *Client) GetUserRoute(userId string) string
- func (c *Client) GetUsersRoute() string
- func (c *Client) Login(loginId string, password string) (*User, *Response)
- func (c *Client) SetOAuthToken(token string)
- type Config
- func (o *Config) GetJWTService() *JWTSettings
- func (o *Config) GetSSOService(service string) *SSOSettings
- func (o *Config) GetSanitizeOptions() map[string]bool
- func (o *Config) GetSmsService() *SmsSettings
- func (o *Config) IsValid() *AppError
- func (o *Config) Sanitize()
- func (o *Config) SetDefaults()
- type CustomClaims
- type EmailSettings
- type EncryptStringMap
- type FileSettings
- type JWTSettings
- type LocalizationSettings
- type LogSettings
- type LoginIdAndPassword
- type OAuthApp
- type PasswordSettings
- type Permission
- type PrivacySettings
- type RateLimitSettings
- type Response
- type Role
- type SSOSettings
- type ScheduledTask
- type ServiceSettings
- type SmsSettings
- type SqlSettings
- type Status
- type StringArray
- type StringInterface
- type StringMap
- type SupportSettings
- type System
- type TaskFunc
- type Token
- type User
- func (u *User) ClearNonProfileFields()
- func (u *User) Etag(showFullName, showEmail bool) string
- func (u *User) GetDisplayName() string
- func (u *User) GetFullName() string
- func (u *User) IsOAuthUser() bool
- func (u *User) IsValid() *AppError
- func (u *User) MakeNonNil()
- func (u *User) PreSave()
- func (u *User) PreUpdate()
- func (u *User) Sanitize(options map[string]bool)
- func (u *User) SanitizeProfile(options map[string]bool)
- func (u *User) SetNames()
- func (u *User) ToJson() string
- func (user *User) UpdateMentionKeysFromUsername(oldUsername string)
- type UserSearch
Constants ¶
View Source
const ( ACCESS_TOKEN_GRANT_TYPE = "authorization_code" ACCESS_TOKEN_TYPE = "bearer" REFRESH_TOKEN_GRANT_TYPE = "refresh_token" )
View Source
const ( HEADER_REQUEST_ID = "X-Request-ID" HEADER_VERSION_ID = "X-Version-ID" HEADER_ETAG_SERVER = "ETag" HEADER_ETAG_CLIENT = "If-None-Match" HEADER_FORWARDED = "X-Forwarded-For" HEADER_REAL_IP = "X-Real-IP" HEADER_FORWARDED_PROTO = "X-Forwarded-Proto" HEADER_TOKEN = "Token" HEADER_BEARER = "BEARER" HEADER_AUTH = "Authorization" HEADER_REQUESTED_WITH = "X-Requested-With" HEADER_REQUESTED_WITH_XML = "XMLHttpRequest" STATUS = "status" STATUS_OK = "OK" LAST_PICTURE_UPDATE = "Last_picture_update" CLIENT_DIR = "webapp/dist" API_URL_SUFFIX = "/sso" )
View Source
const ( DATABASE_DRIVER_MYSQL = "mysql" CONN_SECURITY_NONE = "" CONN_SECURITY_PLAIN = "PLAIN" CONN_SECURITY_TLS = "TLS" CONN_SECURITY_STARTTLS = "STARTTLS" PASSWORD_MAXIMUM_LENGTH = 64 PASSWORD_MINIMUM_LENGTH = 5 SERVICE_WEIXIN = "weixin" WEBSERVER_MODE_REGULAR = "regular" WEBSERVER_MODE_GZIP = "gzip" WEBSERVER_MODE_DISABLED = "disabled" FAKE_SETTING = "********************************" SITENAME_MAX_LENGTH = 30 SERVICE_SETTINGS_DEFAULT_SITE_URL = "" SERVICE_SETTINGS_DEFAULT_TLS_CERT_FILE = "" SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE = "" SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT = 300 SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT = 300 SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM = "" )
View Source
const ( SESSION_COOKIE_TOKEN = "AUTHTOKEN" SESSION_COOKIE_USER = "USERID" SESSION_CACHE_SIZE = 35000 SESSION_PROP_PLATFORM = "platform" SESSION_PROP_OS = "os" SESSION_PROP_BROWSER = "browser" )
View Source
const ( OAUTH_ACTION_SIGNUP = "signup" OAUTH_ACTION_LOGIN = "login" )
View Source
const ( TOKEN_SIZE = 64 MAX_TOKEN_EXIPRY_TIME = 1000 * 60 * 60 * 24 // 24 hour MAX_SMS_TOKEN_EXIPRY_TIME = 1000 * 60 * 1 // 1 min MAX_EMAIL_TOKEN_EXIPRY_TIME = 1000 * 60 * 1 // 1 min SEND_CODE_MAX = 60 TOKEN_TYPE_OAUTH = "oauth" )
View Source
const ( ME = "me" DEFAULT_LOCALE = "zh-CN" USER_EMAIL_MAX_LENGTH = 128 USER_NICKNAME_MAX_RUNES = 64 USER_FIRST_NAME_MAX_RUNES = 64 USER_LAST_NAME_MAX_RUNES = 64 USER_NAME_MAX_LENGTH = 64 USER_NAME_MIN_LENGTH = 3 USER_PASSWORD_MAX_LENGTH = 72 )
View Source
const ( LOWERCASE_LETTERS = "abcdefghijklmnopqrstuvwxyz" UPPERCASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" NUMBERS = "0123456789" SYMBOLS = " !\"\\#$%&'()*+,-./:;<=>?@[]^_`|~" USER_AUTH_SERVICE_LDAP = "ldap" LDAP_SYNC_TASK_NAME = "LDAP Syncronization" )
View Source
const (
SYSTEM_RAN_UNIT_TESTS = "RanUnitTests"
)
View Source
const (
StatusBadRequest = http.StatusBadRequest
)
View Source
const (
USER_AUTH_SERVICE_WECHAT = "weixin"
)
Variables ¶
View Source
var BuildDate string
View Source
var BuildHash string
View Source
var BuildNumber string
View Source
var BuiltInRoles map[string]*Role
View Source
var CurrentVersion string = versions[0]
Functions ¶
func ArrayFromJson ¶
func ArrayToJson ¶
func ComparePassword ¶
func GetAllTasks ¶
func GetAllTasks() *map[string]*ScheduledTask
func GetPreviousVersion ¶
func HashPassword ¶
func InitalizePermissions ¶
func InitalizePermissions()
func InitalizeRoles ¶
func InitalizeRoles()
func IsCurrentVersion ¶
func IsOfficalBuild ¶
func IsOfficalBuild() bool
func IsValidHttpUrl ¶
func IsValidUserRoles ¶
func IsValidUsername ¶
func NewRandomString ¶
func OAuthAppListToJson ¶
func OAuthAppMapToJson ¶
func RoleIdsToString ¶
func StringInterfaceToJson ¶
func UserListToJson ¶
Types ¶
type ALiYunCommunicationRequest ¶
type ALiYunCommunicationRequest struct { //system parameters AccessKeyId string Timestamp string Format string SignatureMethod string SignatureVersion string SignatureNonce string Signature string //business parameters Action string Version string RegionId string PhoneNumbers string SignName string TemplateCode string TemplateParam string SmsUpExtendCode string OutId string }
func (*ALiYunCommunicationRequest) BuildSmsRequestEndpoint ¶
func (req *ALiYunCommunicationRequest) BuildSmsRequestEndpoint(accessKeySecret, gatewayUrl string) (string, error)
func (*ALiYunCommunicationRequest) SetParamsValue ¶
func (req *ALiYunCommunicationRequest) SetParamsValue(accessKeyId, phoneNumbers, signName, templateCode, templateParam string) error
func (*ALiYunCommunicationRequest) SmsParamsIsValid ¶
func (req *ALiYunCommunicationRequest) SmsParamsIsValid() error
type AccessData ¶
type AccessData struct { ClientId string `bson:"clientId" json:"client_id"` UserId string `bson:"userId" json:"user_id"` Token string `bson:"token" json:"token"` RefreshToken string `bson:"refreshToken" json:"refresh_token"` RedirectUri string `bson:"redirectUri" json:"redirect_uri"` ExpiresAt int64 `bson:"expiresAt" json:"expires_at"` Scope string `bson:"scope" json:"scope"` }
func AccessDataFromJson ¶
func AccessDataFromJson(data io.Reader) *AccessData
func (*AccessData) IsExpired ¶
func (me *AccessData) IsExpired() bool
func (*AccessData) IsValid ¶
func (ad *AccessData) IsValid() *AppError
func (*AccessData) ToJson ¶
func (ad *AccessData) ToJson() string
type AccessResponse ¶
type AccessResponse struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int32 `json:"expires_in"` Scope string `json:"scope"` RefreshToken string `json:"refresh_token"` OpenId string `json:"openid"` }
func AccessResponseFromJson ¶
func AccessResponseFromJson(data io.Reader) *AccessResponse
func (*AccessResponse) ToJson ¶
func (ar *AccessResponse) ToJson() string
type AppError ¶
type AppError struct { Id string `json:"id"` Message string `json:"message"` // Message to be display to the end user without debugging information DetailedError string `json:"detailed_error"` // Internal error string to help the developer RequestId string `json:"request_id,omitempty"` // The RequestId that's also set in the header StatusCode int `json:"status_code,omitempty"` // The http status code Where string `json:"-"` // The function where it happened in the form of Struct.Func // contains filtered or unexported fields }
func AppErrorFromJson ¶
AppErrorFromJson will decode the input and return an AppError
func InvalidUserError ¶
func NewAppError ¶
func NewLocAppError ¶
func (*AppError) SystemMessage ¶
func (er *AppError) SystemMessage(T goi18n.TranslateFunc) string
func (*AppError) Translate ¶
func (er *AppError) Translate(T goi18n.TranslateFunc)
type Client ¶
type Client struct { Url string // The location of the server, for example "http://localhost:8065" ApiUrl string // The api location of the server, for example "http://localhost:8065/api/v4" HttpClient *http.Client // The http client AuthToken string AuthType string }
func NewAPIClient ¶
func (*Client) ClearOAuthToken ¶
func (c *Client) ClearOAuthToken()
func (*Client) CreateUser ¶
CreateUser creates a user in the system based on the provided user struct.
func (*Client) DoApiRequest ¶
func (*Client) GetUserRoute ¶
func (*Client) GetUsersRoute ¶
func (*Client) SetOAuthToken ¶
type Config ¶
type Config struct { SqlSettings SqlSettings ServiceSettings ServiceSettings SupportSettings SupportSettings LogSettings LogSettings EmailSettings EmailSettings EnableSignInWithMobile *bool SmsCodeSettings SmsSettings FileSettings FileSettings RateLimitSettings RateLimitSettings PrivacySettings PrivacySettings PasswordSettings PasswordSettings WeixinSettings SSOSettings JWTSettings JWTSettings LocalizationSettings LocalizationSettings }
func (*Config) GetJWTService ¶
func (o *Config) GetJWTService() *JWTSettings
func (*Config) GetSSOService ¶
func (o *Config) GetSSOService(service string) *SSOSettings
func (*Config) GetSanitizeOptions ¶
func (*Config) GetSmsService ¶
func (o *Config) GetSmsService() *SmsSettings
func (*Config) SetDefaults ¶
func (o *Config) SetDefaults()
type CustomClaims ¶
type CustomClaims struct { UserId string `json:"user_id"` Roles string `json:"roles"` Props map[string]string `json:"props"` jwt.StandardClaims }
func (*CustomClaims) AddProp ¶
func (me *CustomClaims) AddProp(key string, value string)
func (*CustomClaims) GetUserRoles ¶
func (me *CustomClaims) GetUserRoles() []string
func (*CustomClaims) IsExpired ¶
func (me *CustomClaims) IsExpired() bool
func (*CustomClaims) SetExpireInDays ¶
func (me *CustomClaims) SetExpireInDays(days int)
type EmailSettings ¶
type EmailSettings struct { EnableSignUpWithEmail bool EnableSignInWithEmail *bool EnableSignInWithUsername *bool FeedbackName string FeedbackEmail string FeedbackOrganization *string EnableSMTPAuth *bool SMTPUsername string SMTPPassword string SMTPServer string SMTPPort string ConnectionSecurity string SkipServerCertificateVerification *bool }
type EncryptStringMap ¶
type FileSettings ¶
type JWTSettings ¶
type LocalizationSettings ¶
type LogSettings ¶
type LoginIdAndPassword ¶
type LoginIdAndPassword struct { LoginId string `json:"login_id"` Password string `json:"password"` }
func (*LoginIdAndPassword) ToJson ¶
func (o *LoginIdAndPassword) ToJson() string
type OAuthApp ¶
type OAuthApp struct { Id string `bson:"_id" json:"id"` CreatorId string `bson:"creatorId" json:"creator_id"` CreateAt int64 `bson:"createAt" json:"create_at"` UpdateAt int64 `bson:"updateAt" json:"update_at"` ClientSecret string `bson:"clientSecret" json:"client_secret"` Name string `bson:"name" json:"name"` Description string `bson:"description" json:"description"` IconURL string `bson:"iconURL" json:"icon_url"` CallbackUrls StringArray `bson:"callbackUrls" json:"callback_urls"` Homepage string `bson:"homepage" json:"homepage"` IsTrusted bool `bson:"isTrusted" json:"is_trusted"` }
func OAuthAppFromJson ¶
OAuthAppFromJson will decode the input and return a User
func OAuthAppListFromJson ¶
func (*OAuthApp) IsValid ¶
IsValid validates the app and returns an error if it isn't configured correctly.
func (*OAuthApp) IsValidRedirectURL ¶
func (*OAuthApp) PreSave ¶
func (a *OAuthApp) PreSave()
PreSave will set the Id and ClientSecret if missing. It will also fill in the CreateAt, UpdateAt times. It should be run before saving the app to the db.
func (*OAuthApp) PreUpdate ¶
func (a *OAuthApp) PreUpdate()
PreUpdate should be run before updating the app in the db.
type PasswordSettings ¶
type Permission ¶
type Permission struct { Id string `json:"id"` Name string `json:"name"` Description string `json:"description"` }
var PERMISSION_ASSIGN_SYSTEM_ADMIN_ROLE *Permission
var PERMISSION_EDIT_OTHER_USERS *Permission
var PERMISSION_MANAGE_ROLES *Permission
var PERMISSION_MANAGE_SYSTEM *Permission
type PrivacySettings ¶
type RateLimitSettings ¶
type Response ¶
type Response struct { StatusCode int Error *AppError RequestId string Etag string ServerVersion string }
func BuildResponse ¶
type Role ¶
type Role struct { Id string `json:"id"` Name string `json:"name"` Description string `json:"description"` Permissions []string `json:"permissions"` }
var ROLE_SYSTEM_ADMIN *Role
var ROLE_USER *Role
type SSOSettings ¶
type ScheduledTask ¶
type ScheduledTask struct { Name string `json:"name"` Interval time.Duration `json:"interval"` Recurring bool `json:"recurring"` // contains filtered or unexported fields }
func CreateRecurringTask ¶
func CreateRecurringTask(name string, function TaskFunc, interval time.Duration) *ScheduledTask
func CreateTask ¶
func CreateTask(name string, function TaskFunc, timeToExecution time.Duration) *ScheduledTask
func GetTaskByName ¶
func GetTaskByName(name string) *ScheduledTask
func (*ScheduledTask) Cancel ¶
func (task *ScheduledTask) Cancel()
func (*ScheduledTask) Execute ¶
func (task *ScheduledTask) Execute()
Executes the task immediatly. A recurring task will be run regularally after interval.
func (*ScheduledTask) String ¶
func (task *ScheduledTask) String() string
type ServiceSettings ¶
type ServiceSettings struct { SiteURL *string SiteName string ListenAddress string ConnectionSecurity *string TLSCertFile *string TLSKeyFile *string Forward80To443 *bool ReadTimeout *int WriteTimeout *int MaximumLoginAttempts int EnableDeveloper *bool AllowCorsFrom *string SessionLengthWebInDays *int SessionCacheInMinutes *int WebserverMode *string EnableInsecureOutgoingConnections *bool AllowedUntrustedInternalConnections *string }
type SmsSettings ¶
type SqlSettings ¶
type StringArray ¶
type StringArray []string
type StringInterface ¶
type StringInterface map[string]interface{}
type SupportSettings ¶
type Token ¶
type Token struct { Token string `bson:"_id"` CreateAt int64 `bson:"createAt"` Type string Props StringInterface `bson:"props" json:"props"` Extra string }
func NewToken ¶
func NewToken(tokentype, extra string, props StringInterface) *Token
type User ¶
type User struct { Id string `bson:"_id" json:"id"` CreateAt int64 `bson:"createAt" json:"create_at,omitempty"` UpdateAt int64 `bson:"updateAt" json:"update_at,omitempty"` DeleteAt int64 `bson:"deleteAt" json:"delete_at"` Username string `bson:"username" json:"username"` Gender string `bson:"gender" json:"gender"` Password string `bson:"password" json:"password,omitempty"` AuthData *string `bson:"authData" json:"auth_data,omitempty"` AuthService string `bson:"authService" json:"auth_service"` Email string `bson:"email" json:"email"` EmailVerified bool `bson:"emailVerified" json:"email_verified,omitempty"` Nickname string `bson:"nickname" json:"nickname"` FirstName string `bson:"firstName" json:"first_name"` LastName string `bson:"lastName" json:"last_name"` Position string `bson:"position" json:"position"` Roles string `bson:"roles" json:"roles"` AllowMarketing bool `bson:"allowMarketing" json:"allow_marketing,omitempty"` Props StringMap `bson:"props" json:"props,omitempty"` NotifyProps StringMap `bson:"notifyProps" json:"notify_props,omitempty"` LastPasswordUpdate int64 `bson:"lastPasswordUpdate" json:"last_password_update,omitempty"` LastPictureUpdate int64 `bson:"lastPictureUpdate" json:"last_picture_update,omitempty"` FailedAttempts int `bson:"failedAttempts" json:"failed_attempts,omitempty"` Locale string `bson:"locale" json:"locale"` MfaActive bool `bson:"mfaActive" json:"mfa_active,omitempty"` MfaSecret string `bson:"mfaSecret" json:"mfa_secret,omitempty"` LastActivityAt int64 `bson:"-" db:"-" json:"last_activity_at,omitempty"` Names []string `bson:"names,omitempty" db:"-" json:"-"` HasTeams bool `bson:"hasTeams" db:"-" json:"-"` HeadImgUrl string `bson:"headImgUrl" json:"-"` Mobile string `bson:"mobile" json:"mobile"` IconUrl string `bson:"icon_url" json:"icon_url"` IdCard string `bson:"id_card" json:"id_card"` Education string `bson:"education" json:"education"` GraduateSchool string `bson:"graduate_school" json:"graduate_school"` TeachingGrade string `bson:"teaching_grade" json:"teaching_grade"` Introduce string `bson:"introduce" json:"introduce"` Interest string `bson:"interest" json:"interest"` Professional string `bson:"professional" json:"professional"` ReviewResult string `bson:"review_result" json:"review_result"` Status int `bson:"status" json:"status"` CreatedAt int64 `bson:"created_at" json:"created_at"` }
func DecodeUserFromJson ¶
func UserFromJson ¶
func UserListFromJson ¶
func (*User) ClearNonProfileFields ¶
func (u *User) ClearNonProfileFields()
func (*User) GetDisplayName ¶
func (*User) GetFullName ¶
func (*User) IsOAuthUser ¶
func (*User) MakeNonNil ¶
func (u *User) MakeNonNil()
func (*User) SanitizeProfile ¶
func (*User) UpdateMentionKeysFromUsername ¶
type UserSearch ¶
func UserSearchFromJson ¶
func UserSearchFromJson(data io.Reader) *UserSearch
UserSearchFromJson will decode the input and return a User
func (*UserSearch) ToJson ¶
func (u *UserSearch) ToJson() string
ToJson convert a User to a json string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.