Documentation ¶
Index ¶
- func CheckResponse(r *http.Response) error
- type AuthenticatedUser
- type Client
- type ErrorResponse
- type Group
- type GroupService
- type OauthService
- type Response
- type Role
- type RoleService
- type User
- type UserService
- func (s *UserService) DeleteUser(ctx context.Context, id int64) error
- func (s *UserService) GetUser(ctx context.Context, id int64) (*User, error)
- func (s *UserService) GetUsers(ctx context.Context) ([]*User, error)
- func (s *UserService) UpdateCustomAttributes(ctx context.Context, id int64, attributes map[string]string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the *http.Response. HTTP status codes ranging from 200 to 299 are considered are successes. Otherwise an error happen, and the error gets unmarshalled and returned into the error.
Types ¶
type AuthenticatedUser ¶
type AuthenticatedUser struct { ID int64 `json:"id"` Username string `json:"username"` Email string `json:"email"` FirstName string `json:"firstname"` LastName string `json:"lastname"` }
AuthenticatedUser contains user information for the Authentication.
type Client ¶
type Client struct { BaseURL *url.URL // User agent used when communicating with the OneLogin api. UserAgent string Oauth *OauthService User *UserService Role *RoleService Group *GroupService sync.Mutex // contains filtered or unexported fields }
A Client interacts with OneLogin.
func (*Client) AddAuthorization ¶
AddAuthorization injects the Authorization header to the request. If the client doesn't has an oauthToken, a new token is issed. If the token is expired, it is automatically refreshed.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
The provided ctx must be non-nil. If it is canceled or times out, ctx.Err() will be returned.
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Code int64 Type string Message string }
An ErrorResponse reports an error caused by an API request. Onelogin always returns Code, Type and a Message associated to the error. Example:
{ "status": { "error": true, "code": 400, "type": "bad request", "message": "Content Type is not specified or specified incorrectly. Content-Type header must be set to application/json" } }
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type OauthService ¶
type OauthService service
OauthService handles communications with the authentication related methods on OneLogin.
func (*OauthService) Authenticate ¶
func (s *OauthService) Authenticate(ctx context.Context, emailOrUsername string, password string) (*AuthenticatedUser, error)
Authenticate a user from an email(or username) and a password. It returns nil on success.
type Response ¶
type Response struct { *http.Response PaginationAfterCursor *string PaginationBeforeCursor *string }
Response embeds a *http.Response as well as some Paginations values.
type User ¶
type User struct { ActivatedAt string `json:"activated_at"` CreatedAt string `json:"created_at"` Email string `json:"email"` Username string `json:"username"` FirstName string `json:"firstname"` GroupID int64 `json:"group_id"` ID int64 `json:"id"` InvalidLoginAttempts int64 `json:"invalid_login_attempts"` InvitationSentAt string `json:"invitation_sent_at"` LastLogin string `json:"last_login"` LastName string `json:"lastname"` LockedUntil string `json:"locked_until"` Notes string `json:"notes"` OpenidName string `json:"openid_name"` LocaleCode string `json:"locale_code"` PasswordChangedAt string `json:"password_changed_at"` Phone string `json:"phone"` Status int64 `json:"status"` UpdatedAt string `json:"updated_at"` DistinguishedName string `json:"distinguished_name"` ExternalID string `json:"external_id"` DirectoryID int64 `json:"directory_id"` MemberOf []string `json:"member_of"` SamAccountName string `json:"samaccountname"` UserPrincipalName string `json:"userprincipalname"` ManagerAdID int `json:"manager_ad_id"` RoleIDs []int64 `json:"role_id"` CustomAttributes map[string]string `json:"custom_attributes"` }
User represents a OneLogin user.
type UserService ¶
type UserService service
UserService handles communications with the authentication related methods on OneLogin.
func (*UserService) DeleteUser ¶
func (s *UserService) DeleteUser(ctx context.Context, id int64) error
DeleteUser delete a OneLogin user.
func (*UserService) GetUsers ¶
func (s *UserService) GetUsers(ctx context.Context) ([]*User, error)
GetUsers returns all the OneLogin users.
func (*UserService) UpdateCustomAttributes ¶
func (s *UserService) UpdateCustomAttributes(ctx context.Context, id int64, attributes map[string]string) error
UpdateCustomAttributes returns a OneLogin user.