Documentation ¶
Overview ¶
This is a client module to support server-side use of the Tidepool service called user-api.
Index ¶
- Constants
- Variables
- func ExtractArray(data map[string]interface{}, key string) ([]interface{}, bool)
- func ExtractBool(data map[string]interface{}, key string) (*bool, bool)
- func ExtractString(data map[string]interface{}, key string) (*string, bool)
- func ExtractStringArray(data map[string]interface{}, key string) ([]string, bool)
- func ExtractStringMap(data map[string]interface{}, key string) (map[string]interface{}, bool)
- func GeneratePasswordHash(id, pw, salt string) (string, error)
- func IsValidDate(date string) bool
- func IsValidEmail(email string) bool
- func IsValidPassword(password string) bool
- func IsValidRole(role string) bool
- func IsValidTimestamp(timestamp string) bool
- type AnonIdHashPair
- type Api
- func (a *Api) AnonymousIdHashPair(res http.ResponseWriter, req *http.Request)
- func (a *Api) AttachPerms(perms clients.Gatekeeper)
- func (a *Api) CreateCustodialUser(res http.ResponseWriter, req *http.Request, vars map[string]string)
- func (a *Api) CreateUser(res http.ResponseWriter, req *http.Request)
- func (a *Api) DeleteUser(res http.ResponseWriter, req *http.Request, vars map[string]string)
- func (a *Api) GetStatus(res http.ResponseWriter, req *http.Request)
- func (a *Api) GetUserInfo(res http.ResponseWriter, req *http.Request, vars map[string]string)
- func (a *Api) GetUsers(res http.ResponseWriter, req *http.Request)
- func (a *Api) Login(res http.ResponseWriter, req *http.Request)
- func (a *Api) Logout(res http.ResponseWriter, req *http.Request)
- func (a *Api) LongtermLogin(res http.ResponseWriter, req *http.Request, vars map[string]string)
- func (a *Api) RefreshSession(res http.ResponseWriter, req *http.Request)
- func (a *Api) ServerCheckToken(res http.ResponseWriter, req *http.Request, vars map[string]string)
- func (a *Api) ServerLogin(res http.ResponseWriter, req *http.Request)
- func (a *Api) SetHandlers(prefix string, rtr *mux.Router)
- func (a *Api) UpdateUser(res http.ResponseWriter, req *http.Request, vars map[string]string)
- type ApiConfig
- type FindTokenByIDResponse
- type FindUserResponse
- type FindUsersByRoleResponse
- type FindUsersResponse
- type FindUsersWithIdsResponse
- type IdHashPair
- type MockStoreClient
- func (d MockStoreClient) AddToken(token *SessionToken) error
- func (d *MockStoreClient) EnsureIndexes() error
- func (d MockStoreClient) FindTokenByID(id string) (*SessionToken, error)
- func (d MockStoreClient) FindUser(user *User) (found *User, err error)
- func (d MockStoreClient) FindUsers(user *User) (found []*User, err error)
- func (d MockStoreClient) FindUsersByRole(role string) (found []*User, err error)
- func (d MockStoreClient) FindUsersWithIds(ids []string) (found []*User, err error)
- func (d MockStoreClient) Ping() error
- func (d MockStoreClient) RemoveTokenByID(id string) error
- func (d MockStoreClient) RemoveUser(user *User) error
- func (d MockStoreClient) UpsertUser(user *User) error
- func (d *MockStoreClient) WithContext(ctx context.Context) Storage
- type MongoStoreClient
- func (msc *MongoStoreClient) AddToken(st *SessionToken) error
- func (msc *MongoStoreClient) Disconnect() error
- func (msc *MongoStoreClient) EnsureIndexes() error
- func (msc *MongoStoreClient) FindTokenByID(id string) (*SessionToken, error)
- func (msc *MongoStoreClient) FindUser(user *User) (result *User, err error)
- func (msc *MongoStoreClient) FindUsers(user *User) (results []*User, err error)
- func (msc *MongoStoreClient) FindUsersByRole(role string) (results []*User, err error)
- func (msc *MongoStoreClient) FindUsersWithIds(ids []string) (results []*User, err error)
- func (msc *MongoStoreClient) Ping() error
- func (msc *MongoStoreClient) RemoveTokenByID(id string) (err error)
- func (msc *MongoStoreClient) RemoveUser(user *User) (err error)
- func (msc *MongoStoreClient) UpsertUser(user *User) error
- func (msc *MongoStoreClient) WithContext(ctx context.Context) Storage
- type NewCustodialUserDetails
- type NewUserDetails
- type PermissionsResponse
- type ResponsableMockGatekeeper
- func (c *ResponsableMockGatekeeper) HasResponses() bool
- func (c *ResponsableMockGatekeeper) Reset()
- func (c *ResponsableMockGatekeeper) SetPermissions(userID, groupID string, permissions clients.Permissions) (clients.Permissions, error)
- func (c *ResponsableMockGatekeeper) UserInGroup(userID, groupID string) (clients.Permissions, error)
- func (c *ResponsableMockGatekeeper) UsersInGroup(groupID string) (clients.UsersPermissions, error)
- type ResponsableMockStoreClient
- func (r *ResponsableMockStoreClient) AddToken(token *SessionToken) (err error)
- func (r *ResponsableMockStoreClient) EnsureIndexes() error
- func (r *ResponsableMockStoreClient) FindTokenByID(id string) (*SessionToken, error)
- func (r *ResponsableMockStoreClient) FindUser(user *User) (found *User, err error)
- func (r *ResponsableMockStoreClient) FindUsers(user *User) (found []*User, err error)
- func (r *ResponsableMockStoreClient) FindUsersByRole(role string) (found []*User, err error)
- func (r *ResponsableMockStoreClient) FindUsersWithIds(ids []string) (found []*User, err error)
- func (r *ResponsableMockStoreClient) HasResponses() bool
- func (r *ResponsableMockStoreClient) Ping() (err error)
- func (r *ResponsableMockStoreClient) RemoveTokenByID(id string) (err error)
- func (r *ResponsableMockStoreClient) RemoveUser(user *User) (err error)
- func (r *ResponsableMockStoreClient) Reset()
- func (r *ResponsableMockStoreClient) UpsertUser(user *User) (err error)
- func (r *ResponsableMockStoreClient) WithContext(ctx context.Context) Storage
- type SessionToken
- type Storage
- type TokenConfig
- type TokenData
- type UpdateUserDetails
- type User
- func (u *User) DeepClone() *User
- func (u *User) Email() string
- func (u *User) HasRole(role string) bool
- func (u *User) HashPassword(pw, salt string) error
- func (u *User) IsClinic() bool
- func (u *User) IsDeleted() bool
- func (u *User) IsEmailVerified(secret string) bool
- func (u *User) PasswordsMatch(pw, salt string) bool
- type UserClient
- func (client *UserClient) CheckToken(token string) *commonUserApi.TokenData
- func (client *UserClient) Close()
- func (client *UserClient) GetUser(userID, token string) (*commonUserApi.UserData, error)
- func (client *UserClient) Login(username, password string) (*commonUserApi.UserData, string, error)
- func (client *UserClient) Signup(username, password, email string) (*commonUserApi.UserData, error)
- func (client *UserClient) Start() error
- func (client *UserClient) TokenProvide() string
- func (client *UserClient) UpdateUser(userID string, userUpdate commonUserApi.UserUpdate, token string) error
- type UsersPermissionsResponse
Constants ¶
const ( //api logging prefix USER_API_PREFIX = "api/user " TP_SERVER_NAME = "x-tidepool-server-name" TP_SERVER_SECRET = "x-tidepool-server-secret" TP_SESSION_TOKEN = "x-tidepool-session-token" STATUS_NO_USR_DETAILS = "No user details were given" STATUS_INVALID_USER_DETAILS = "Invalid user details were given" STATUS_USER_NOT_FOUND = "User not found" STATUS_ERR_FINDING_USR = "Error finding user" STATUS_ERR_CREATING_USR = "Error creating the user" STATUS_ERR_UPDATING_USR = "Error updating user" STATUS_USR_ALREADY_EXISTS = "User already exists" STATUS_ERR_GENERATING_TOKEN = "Error generating the token" STATUS_ERR_UPDATING_TOKEN = "Error updating token" STATUS_MISSING_USR_DETAILS = "Not all required details were given" STATUS_ERROR_UPDATING_PW = "Error updating password" STATUS_MISSING_ID_PW = "Missing id and/or password" STATUS_NO_MATCH = "No user matched the given details" STATUS_NOT_VERIFIED = "The user hasn't verified this account yet" STATUS_NO_TOKEN_MATCH = "No token matched the given details" STATUS_PW_WRONG = "Wrong password" STATUS_ERR_SENDING_EMAIL = "Error sending email" STATUS_NO_TOKEN = "No x-tidepool-session-token was found" STATUS_SERVER_TOKEN_REQUIRED = "A server token is required" STATUS_AUTH_HEADER_REQUIRED = "Authorization header is required" STATUS_AUTH_HEADER_INVALID = "Authorization header is invalid" STATUS_GETSTATUS_ERR = "Error checking service status" STATUS_UNAUTHORIZED = "Not authorized for requested operation" STATUS_NO_QUERY = "A query must be specified" STATUS_PARAMETER_UNKNOWN = "Unknown query parameter" STATUS_ONE_QUERY_PARAM = "Only one query parameter is allowed" STATUS_INVALID_ROLE = "The role specified is invalid" )
const (
TOKEN_DURATION_KEY = "tokenduration"
)
Variables ¶
var ( SessionToken_error_no_userid = errors.New("SessionToken: userId not set") SessionToken_invalid = errors.New("SessionToken: is invalid") SessionToken_error_duration_not_set = errors.New("SessionToken: duration not set") )
var ( User_error_details_missing = errors.New("User details are missing") User_error_username_missing = errors.New("Username is missing") User_error_username_invalid = errors.New("Username is invalid") User_error_emails_missing = errors.New("Emails are missing") User_error_emails_invalid = errors.New("Emails are invalid") User_error_password_missing = errors.New("Password is missing") User_error_password_invalid = errors.New("Password is invalid") User_error_roles_invalid = errors.New("Roles are invalid") User_error_terms_accepted_invalid = errors.New("Terms accepted is invalid") User_error_email_verified_invalid = errors.New("Email verified is invalid") )
Functions ¶
func ExtractArray ¶
func ExtractStringArray ¶
func ExtractStringMap ¶
func GeneratePasswordHash ¶
func IsValidDate ¶
func IsValidEmail ¶
func IsValidPassword ¶
func IsValidRole ¶
func IsValidTimestamp ¶
Types ¶
type AnonIdHashPair ¶
type AnonIdHashPair struct { Name string `json:"name"` Id string `json:"id"` Hash string `json:"hash"` }
func NewAnonIdHashPair ¶
func NewAnonIdHashPair(baseStrings []string, params map[string][]string) *AnonIdHashPair
type Api ¶
func (*Api) AnonymousIdHashPair ¶
func (a *Api) AnonymousIdHashPair(res http.ResponseWriter, req *http.Request)
status: 200 AnonIdHashPair
func (*Api) AttachPerms ¶
func (a *Api) AttachPerms(perms clients.Gatekeeper)
func (*Api) CreateCustodialUser ¶
func (a *Api) CreateCustodialUser(res http.ResponseWriter, req *http.Request, vars map[string]string)
CreateCustodialUser creates a new custodial user status: 201 User status: 400 STATUS_MISSING_USR_DETAILS status: 401 STATUS_UNAUTHORIZED status: 409 STATUS_USR_ALREADY_EXISTS status: 500 STATUS_ERR_GENERATING_TOKEN
func (*Api) CreateUser ¶
func (a *Api) CreateUser(res http.ResponseWriter, req *http.Request)
CreateUser creates a new user status: 201 User status: 400 STATUS_MISSING_USR_DETAILS status: 409 STATUS_USR_ALREADY_EXISTS status: 500 STATUS_ERR_GENERATING_TOKEN
func (*Api) DeleteUser ¶
func (*Api) GetUserInfo ¶
GetUserInfo returns user info status: 200 status: 401 STATUS_UNAUTHORIZED status: 500 STATUS_ERR_FINDING_USR
func (*Api) GetUsers ¶
func (a *Api) GetUsers(res http.ResponseWriter, req *http.Request)
GetUsers returns all users status: 200 status: 400 STATUS_NO_QUERY, STATUS_PARAMETER_UNKNOWN status: 401 STATUS_SERVER_TOKEN_REQUIRED status: 500 STATUS_ERR_FINDING_USR
func (*Api) Login ¶
func (a *Api) Login(res http.ResponseWriter, req *http.Request)
status: 200 TP_SESSION_TOKEN, status: 400 STATUS_MISSING_ID_PW status: 401 STATUS_NO_MATCH status: 403 STATUS_NOT_VERIFIED status: 500 STATUS_ERR_FINDING_USR, STATUS_ERR_UPDATING_TOKEN
func (*Api) LongtermLogin ¶
Set the longeterm duration and then process as per Login note: see Login for return codes
func (*Api) RefreshSession ¶
func (a *Api) RefreshSession(res http.ResponseWriter, req *http.Request)
status: 200 TP_SESSION_TOKEN, TokenData status: 401 STATUS_NO_TOKEN status: 500 STATUS_ERR_GENERATING_TOKEN
func (*Api) ServerCheckToken ¶
status: 200 TP_SESSION_TOKEN, TokenData status: 401 STATUS_NO_TOKEN status: 404 STATUS_NO_TOKEN_MATCH
func (*Api) ServerLogin ¶
func (a *Api) ServerLogin(res http.ResponseWriter, req *http.Request)
status: 200 TP_SESSION_TOKEN status: 400 STATUS_MISSING_ID_PW status: 401 STATUS_PW_WRONG status: 500 STATUS_ERR_GENERATING_TOKEN
func (*Api) UpdateUser ¶
UpdateUser updates a user status: 200 status: 400 STATUS_INVALID_USER_DETAILS status: 409 STATUS_USR_ALREADY_EXISTS status: 500 STATUS_ERR_FINDING_USR status: 500 STATUS_ERR_UPDATING_USR
type ApiConfig ¶
type ApiConfig struct { ServerSecret string `json:"serverSercret"` TokenConfigs []TokenConfig `json:"tokenConfigs"` // the first token config is used for encoding new tokens LongTermKey string `json:"longTermKey"` LongTermDaysDuration int `json:"longTermDaysDuration"` Salt string `json:"salt"` VerificationSecret string `json:"verificationSecret"` ClinicDemoUserID string `json:"clinicDemoUserId"` Marketo marketo.Config `json:"marketo"` }
type FindTokenByIDResponse ¶
type FindTokenByIDResponse struct { SessionToken *SessionToken Error error }
type FindUserResponse ¶
type FindUsersByRoleResponse ¶
type FindUsersResponse ¶
type FindUsersWithIdsResponse ¶ added in v0.15.0
type IdHashPair ¶
func NewIdHashPair ¶
func NewIdHashPair(baseStrings []string, params map[string][]string) *IdHashPair
type MockStoreClient ¶
type MockStoreClient struct {
// contains filtered or unexported fields
}
func NewMockStoreClient ¶
func NewMockStoreClient(salt string, returnDifferent, doBad bool) *MockStoreClient
func (MockStoreClient) AddToken ¶
func (d MockStoreClient) AddToken(token *SessionToken) error
func (*MockStoreClient) EnsureIndexes ¶ added in v0.16.0
func (d *MockStoreClient) EnsureIndexes() error
func (MockStoreClient) FindTokenByID ¶
func (d MockStoreClient) FindTokenByID(id string) (*SessionToken, error)
func (MockStoreClient) FindUser ¶
func (d MockStoreClient) FindUser(user *User) (found *User, err error)
func (MockStoreClient) FindUsers ¶
func (d MockStoreClient) FindUsers(user *User) (found []*User, err error)
func (MockStoreClient) FindUsersByRole ¶
func (d MockStoreClient) FindUsersByRole(role string) (found []*User, err error)
func (MockStoreClient) FindUsersWithIds ¶ added in v0.15.0
func (d MockStoreClient) FindUsersWithIds(ids []string) (found []*User, err error)
func (MockStoreClient) Ping ¶
func (d MockStoreClient) Ping() error
func (MockStoreClient) RemoveTokenByID ¶
func (d MockStoreClient) RemoveTokenByID(id string) error
func (MockStoreClient) RemoveUser ¶
func (d MockStoreClient) RemoveUser(user *User) error
func (MockStoreClient) UpsertUser ¶
func (d MockStoreClient) UpsertUser(user *User) error
func (*MockStoreClient) WithContext ¶ added in v0.16.0
func (d *MockStoreClient) WithContext(ctx context.Context) Storage
type MongoStoreClient ¶
type MongoStoreClient struct {
// contains filtered or unexported fields
}
MongoStoreClient - Mongo Storage Client
func NewMongoStoreClient ¶
func NewMongoStoreClient(config *tpMongo.Config) *MongoStoreClient
NewMongoStoreClient creates a new MongoStoreClient
func (*MongoStoreClient) AddToken ¶
func (msc *MongoStoreClient) AddToken(st *SessionToken) error
AddToken to the token collection
func (*MongoStoreClient) Disconnect ¶ added in v0.16.0
func (msc *MongoStoreClient) Disconnect() error
Disconnect from the MongoDB database
func (*MongoStoreClient) EnsureIndexes ¶ added in v0.16.0
func (msc *MongoStoreClient) EnsureIndexes() error
EnsureIndexes exist for the MongoDB collection. EnsureIndexes uses the Background() context, in order to pass back the MongoDB errors, rather than any context errors.
func (*MongoStoreClient) FindTokenByID ¶
func (msc *MongoStoreClient) FindTokenByID(id string) (*SessionToken, error)
FindTokenByID - find an auth token by its ID
func (*MongoStoreClient) FindUser ¶
func (msc *MongoStoreClient) FindUser(user *User) (result *User, err error)
FindUser - find and return an existing user
func (*MongoStoreClient) FindUsers ¶
func (msc *MongoStoreClient) FindUsers(user *User) (results []*User, err error)
FindUsers - find and return multiple existing users
func (*MongoStoreClient) FindUsersByRole ¶
func (msc *MongoStoreClient) FindUsersByRole(role string) (results []*User, err error)
FindUsersByRole - find and return multiple users matching a Role
func (*MongoStoreClient) FindUsersWithIds ¶ added in v0.15.0
func (msc *MongoStoreClient) FindUsersWithIds(ids []string) (results []*User, err error)
FindUsersWithIds - find and return multiple users by Tidepool User ID
func (*MongoStoreClient) RemoveTokenByID ¶
func (msc *MongoStoreClient) RemoveTokenByID(id string) (err error)
RemoveTokenByID - delete an auth token matching an ID
func (*MongoStoreClient) RemoveUser ¶
func (msc *MongoStoreClient) RemoveUser(user *User) (err error)
RemoveUser - Remove a user from the database
func (*MongoStoreClient) UpsertUser ¶
func (msc *MongoStoreClient) UpsertUser(user *User) error
UpsertUser - Update an existing user's details, or insert a new user if the user doesn't already exist.
func (*MongoStoreClient) WithContext ¶ added in v0.16.0
func (msc *MongoStoreClient) WithContext(ctx context.Context) Storage
WithContext returns a shallow copy of c with its context changed to ctx. The provided ctx must be non-nil.
type NewCustodialUserDetails ¶
func ParseNewCustodialUserDetails ¶
func ParseNewCustodialUserDetails(reader io.Reader) (*NewCustodialUserDetails, error)
func (*NewCustodialUserDetails) ExtractFromJSON ¶
func (details *NewCustodialUserDetails) ExtractFromJSON(reader io.Reader) error
func (*NewCustodialUserDetails) Validate ¶
func (details *NewCustodialUserDetails) Validate() error
type NewUserDetails ¶
* Incoming user details used to create or update a `User`
func ParseNewUserDetails ¶
func ParseNewUserDetails(reader io.Reader) (*NewUserDetails, error)
func (*NewUserDetails) ExtractFromJSON ¶
func (details *NewUserDetails) ExtractFromJSON(reader io.Reader) error
func (*NewUserDetails) Validate ¶
func (details *NewUserDetails) Validate() error
type PermissionsResponse ¶
type PermissionsResponse struct { Permissions clients.Permissions Error error }
type ResponsableMockGatekeeper ¶
type ResponsableMockGatekeeper struct { UserInGroupResponses []PermissionsResponse UsersInGroupResponses []UsersPermissionsResponse SetPermissionsResponses []PermissionsResponse }
func NewResponsableMockGatekeeper ¶
func NewResponsableMockGatekeeper() *ResponsableMockGatekeeper
func (*ResponsableMockGatekeeper) HasResponses ¶
func (c *ResponsableMockGatekeeper) HasResponses() bool
func (*ResponsableMockGatekeeper) Reset ¶
func (c *ResponsableMockGatekeeper) Reset()
func (*ResponsableMockGatekeeper) SetPermissions ¶
func (c *ResponsableMockGatekeeper) SetPermissions(userID, groupID string, permissions clients.Permissions) (clients.Permissions, error)
func (*ResponsableMockGatekeeper) UserInGroup ¶
func (c *ResponsableMockGatekeeper) UserInGroup(userID, groupID string) (clients.Permissions, error)
func (*ResponsableMockGatekeeper) UsersInGroup ¶
func (c *ResponsableMockGatekeeper) UsersInGroup(groupID string) (clients.UsersPermissions, error)
type ResponsableMockStoreClient ¶
type ResponsableMockStoreClient struct { PingResponses []error UpsertUserResponses []error FindUsersResponses []FindUsersResponse FindUsersByRoleResponses []FindUsersByRoleResponse FindUsersWithIdsResponses []FindUsersWithIdsResponse FindUserResponses []FindUserResponse RemoveUserResponses []error AddTokenResponses []error FindTokenByIDResponses []FindTokenByIDResponse RemoveTokenByIDResponses []error }
func NewResponsableMockStoreClient ¶
func NewResponsableMockStoreClient() *ResponsableMockStoreClient
func (*ResponsableMockStoreClient) AddToken ¶
func (r *ResponsableMockStoreClient) AddToken(token *SessionToken) (err error)
func (*ResponsableMockStoreClient) EnsureIndexes ¶ added in v0.16.0
func (r *ResponsableMockStoreClient) EnsureIndexes() error
func (*ResponsableMockStoreClient) FindTokenByID ¶
func (r *ResponsableMockStoreClient) FindTokenByID(id string) (*SessionToken, error)
func (*ResponsableMockStoreClient) FindUser ¶
func (r *ResponsableMockStoreClient) FindUser(user *User) (found *User, err error)
func (*ResponsableMockStoreClient) FindUsers ¶
func (r *ResponsableMockStoreClient) FindUsers(user *User) (found []*User, err error)
func (*ResponsableMockStoreClient) FindUsersByRole ¶
func (r *ResponsableMockStoreClient) FindUsersByRole(role string) (found []*User, err error)
func (*ResponsableMockStoreClient) FindUsersWithIds ¶ added in v0.15.0
func (r *ResponsableMockStoreClient) FindUsersWithIds(ids []string) (found []*User, err error)
func (*ResponsableMockStoreClient) HasResponses ¶
func (r *ResponsableMockStoreClient) HasResponses() bool
func (*ResponsableMockStoreClient) Ping ¶
func (r *ResponsableMockStoreClient) Ping() (err error)
func (*ResponsableMockStoreClient) RemoveTokenByID ¶
func (r *ResponsableMockStoreClient) RemoveTokenByID(id string) (err error)
func (*ResponsableMockStoreClient) RemoveUser ¶
func (r *ResponsableMockStoreClient) RemoveUser(user *User) (err error)
func (*ResponsableMockStoreClient) Reset ¶
func (r *ResponsableMockStoreClient) Reset()
func (*ResponsableMockStoreClient) UpsertUser ¶
func (r *ResponsableMockStoreClient) UpsertUser(user *User) (err error)
func (*ResponsableMockStoreClient) WithContext ¶ added in v0.16.0
func (r *ResponsableMockStoreClient) WithContext(ctx context.Context) Storage
type SessionToken ¶
type SessionToken struct { ID string `json:"-" bson:"_id"` IsServer bool `json:"isServer" bson:"isServer"` ServerID string `json:"-" bson:"serverId,omitempty"` UserID string `json:"userId,omitempty" bson:"userId,omitempty"` Duration int64 `json:"-" bson:"duration"` ExpiresAt time.Time `json:"-" bson:"expiresAt"` CreatedAt time.Time `json:"-" bson:"createdAt"` Time time.Time `json:"-" bson:"time"` }
func CreateSessionToken ¶
func CreateSessionToken(data *TokenData, config TokenConfig) (*SessionToken, error)
func CreateSessionTokenAndSave ¶
func CreateSessionTokenAndSave(data *TokenData, config TokenConfig, store Storage) (*SessionToken, error)
type Storage ¶
type Storage interface { Ping() error WithContext(ctx context.Context) Storage EnsureIndexes() error UpsertUser(user *User) error FindUser(user *User) (*User, error) FindUsers(user *User) ([]*User, error) FindUsersByRole(role string) ([]*User, error) FindUsersWithIds(role []string) ([]*User, error) RemoveUser(user *User) error AddToken(token *SessionToken) error FindTokenByID(id string) (*SessionToken, error) RemoveTokenByID(id string) error }
Storage interface
type TokenConfig ¶
type TokenData ¶
type TokenData struct { IsServer bool `json:"isserver"` UserId string `json:"userid"` DurationSecs int64 `json:"-"` }
func UnpackSessionTokenAndVerify ¶
func UnpackSessionTokenAndVerify(id string, tokenConfigs ...TokenConfig) (*TokenData, error)
type UpdateUserDetails ¶
type UpdateUserDetails struct { Username *string Emails []string Password *string Roles []string TermsAccepted *string EmailVerified *bool }
func ParseUpdateUserDetails ¶
func ParseUpdateUserDetails(reader io.Reader) (*UpdateUserDetails, error)
func (*UpdateUserDetails) ExtractFromJSON ¶
func (details *UpdateUserDetails) ExtractFromJSON(reader io.Reader) error
func (*UpdateUserDetails) Validate ¶
func (details *UpdateUserDetails) Validate() error
type User ¶
type User struct { Id string `json:"userid,omitempty" bson:"userid,omitempty"` // map userid to id Username string `json:"username,omitempty" bson:"username,omitempty"` Emails []string `json:"emails,omitempty" bson:"emails,omitempty"` Roles []string `json:"roles,omitempty" bson:"roles,omitempty"` TermsAccepted string `json:"termsAccepted,omitempty" bson:"termsAccepted,omitempty"` EmailVerified bool `json:"emailVerified" bson:"authenticated"` //tag is name `authenticated` for historical reasons PwHash string `json:"-" bson:"pwhash,omitempty"` Hash string `json:"-" bson:"userhash,omitempty"` Private map[string]*IdHashPair `json:"-" bson:"private"` CreatedTime string `json:"createdTime,omitempty" bson:"createdTime,omitempty"` CreatedUserID string `json:"createdUserId,omitempty" bson:"createdUserId,omitempty"` ModifiedTime string `json:"modifiedTime,omitempty" bson:"modifiedTime,omitempty"` ModifiedUserID string `json:"modifiedUserId,omitempty" bson:"modifiedUserId,omitempty"` DeletedTime string `json:"deletedTime,omitempty" bson:"deletedTime,omitempty"` DeletedUserID string `json:"deletedUserId,omitempty" bson:"deletedUserId,omitempty"` }
func NewCustodialUser ¶
func NewCustodialUser(details *NewCustodialUserDetails, salt string) (user *User, err error)
func (*User) HashPassword ¶
func (*User) IsEmailVerified ¶
func (*User) PasswordsMatch ¶
type UserClient ¶
type UserClient struct {
// contains filtered or unexported fields
}
Expose functionality to internal services
func NewUserClient ¶
func NewUserClient(api *Api) *UserClient
func (*UserClient) CheckToken ¶
func (client *UserClient) CheckToken(token string) *commonUserApi.TokenData
func (*UserClient) GetUser ¶
func (client *UserClient) GetUser(userID, token string) (*commonUserApi.UserData, error)
FIXME: Not required for OAUTH API, but still...
func (*UserClient) Login ¶
func (client *UserClient) Login(username, password string) (*commonUserApi.UserData, string, error)
func (*UserClient) Signup ¶
func (client *UserClient) Signup(username, password, email string) (*commonUserApi.UserData, error)
func (*UserClient) Start ¶
func (client *UserClient) Start() error
func (*UserClient) TokenProvide ¶
func (client *UserClient) TokenProvide() string
func (*UserClient) UpdateUser ¶
func (client *UserClient) UpdateUser(userID string, userUpdate commonUserApi.UserUpdate, token string) error
FIXME: Not required for OAUTH API, but still...
type UsersPermissionsResponse ¶
type UsersPermissionsResponse struct { UsersPermissions clients.UsersPermissions Error error }