Documentation
¶
Index ¶
- Constants
- func GenerateMfaSelect(devices []MfaDevice) *[]MfaSelect
- func SelectMfaDevice(mfaDevices []MfaDevice) int32
- type AccessTokenResponse
- type MFA
- type MFAType
- type MfaDevice
- type MfaSelect
- type OneLogin
- type OneLoginCache
- func (olc *OneLoginCache) GetAccessToken() (string, error)
- func (olc *OneLoginCache) GetAssertion(app_id uint32) (string, error)
- func (ols *OneLoginCache) GetRoles(app_id uint32) ([]string, error)
- func (olc *OneLoginCache) Save() error
- func (olc *OneLoginCache) SaveAccessToken(token *AccessTokenResponse) error
- func (olc *OneLoginCache) SaveAssertion(app_id uint32, assertion string) error
- type OneLoginSAML
- func (ols *OneLoginSAML) BuildSAMLInput(app_id uint32, options SAMLInputOptions) (*sts.AssumeRoleWithSAMLInput, error)
- func (ols *OneLoginSAML) GetAssertion(username string, password string, subdomain string, app_id uint32, ip string) (bool, error)
- func (ols *OneLoginSAML) GetMfaType(deviceId int32) (MFAType, error)
- func (ols *OneLoginSAML) GetMfaTypeString(deviceId int32) (string, error)
- func (ols *OneLoginSAML) HasAssertion(app_id uint32) bool
- func (ols *OneLoginSAML) OneLoginProtectPush(app_id uint32, tries uint32) (bool, error)
- func (ols *OneLoginSAML) PromptMFA() (int32, error)
- func (ols *OneLoginSAML) SubmitMFA(deviceId int32, appid uint32) (bool, error)
- func (ols *OneLoginSAML) SubmitMFACode(app_id uint32, device_id int32, mfa_code int32) (bool, error)
- type OneLoginStatus
- type OneLoginUser
- type RateLimit
- type RateLimitData
- type SAMLAssertion
- type SAMLInputOptions
- type SAMLResponse
Constants ¶
const HEADER_TAG = "header"
Variables ¶
This section is empty.
Functions ¶
func GenerateMfaSelect ¶
func SelectMfaDevice ¶
Types ¶
type AccessTokenResponse ¶
type AccessTokenResponse struct {
AccessToken string `json:"access_token"`
CreatedAt string `json:"created_at"`
ExpiresIn int64 `json:"expires_in"`
TokenType string `json:"token_type"`
AccountId int64 `json:"account_id"`
}
func (*AccessTokenResponse) ExpiresAt ¶
func (token *AccessTokenResponse) ExpiresAt() string
returns when our token expires
func (*AccessTokenResponse) IsExpired ¶
func (token *AccessTokenResponse) IsExpired() bool
returns true if the given OAuth2 token has expired
type MFA ¶
type MFA struct {
// Fields when we need MFA
StateToken string `json:"state_token"`
Devices []MfaDevice `json:"devices"`
CallbackUrl string `json:"callback_url"`
User *OneLoginUser `json:"user"`
// contains filtered or unexported fields
}
func (*MFA) OneLoginProtectPush ¶
returns json encoded result
type MfaDevice ¶
type MfaSelect ¶
type OneLogin ¶
type OneLogin struct {
Client *resty.Client
Cache *OneLoginCache
Url string // api url for onelogin
AccessToken string // generated via OAuth2. Required for all other API calls
}
func NewOneLogin ¶
* Returns a new OneLogin struct with our AccessToken configured * * OneLogin OAuth2 tokens are good for 10hrs
func (*OneLogin) GetRateLimit ¶
* There is a rate limit for generating auth tokens: * https://developers.onelogin.com/api-docs/2/oauth20-tokens/generate-tokens-2 * * This API call returns how many calls have been made. * Not valid with Authentication Only tokens
type OneLoginCache ¶
type OneLoginCache struct {
Assertion map[string]SAMLAssertion `json:"assertion"`
AccessToken AccessTokenResponse `json:"accesstoken"`
// contains filtered or unexported fields
}
func LoadOneLoginCache ¶
func LoadOneLoginCache(filename string) *OneLoginCache
func (*OneLoginCache) GetAccessToken ¶
func (olc *OneLoginCache) GetAccessToken() (string, error)
func (*OneLoginCache) GetAssertion ¶
func (olc *OneLoginCache) GetAssertion(app_id uint32) (string, error)
func (*OneLoginCache) GetRoles ¶
func (ols *OneLoginCache) GetRoles(app_id uint32) ([]string, error)
func (*OneLoginCache) Save ¶
func (olc *OneLoginCache) Save() error
func (*OneLoginCache) SaveAccessToken ¶
func (olc *OneLoginCache) SaveAccessToken(token *AccessTokenResponse) error
func (*OneLoginCache) SaveAssertion ¶
func (olc *OneLoginCache) SaveAssertion(app_id uint32, assertion string) error
saves our assertion in our keychain
type OneLoginSAML ¶
type OneLoginSAML struct {
OneLogin *OneLogin
Response *SAMLResponse
}
func NewOneLoginSAML ¶
func NewOneLoginSAML(o *OneLogin) *OneLoginSAML
func (*OneLoginSAML) BuildSAMLInput ¶
func (ols *OneLoginSAML) BuildSAMLInput(app_id uint32, options SAMLInputOptions) (*sts.AssumeRoleWithSAMLInput, error)
func (*OneLoginSAML) GetAssertion ¶
func (ols *OneLoginSAML) GetAssertion(username string, password string, subdomain string, app_id uint32, ip string) (bool, error)
Returns true/false if MFA is required, list of devices is in ols.Response.Devices
func (*OneLoginSAML) GetMfaType ¶
func (ols *OneLoginSAML) GetMfaType(deviceId int32) (MFAType, error)
func (*OneLoginSAML) GetMfaTypeString ¶
func (ols *OneLoginSAML) GetMfaTypeString(deviceId int32) (string, error)
func (*OneLoginSAML) HasAssertion ¶
func (ols *OneLoginSAML) HasAssertion(app_id uint32) bool
func (*OneLoginSAML) OneLoginProtectPush ¶
func (ols *OneLoginSAML) OneLoginProtectPush(app_id uint32, tries uint32) (bool, error)
Returns true/false if we got our assertion
func (*OneLoginSAML) PromptMFA ¶
func (ols *OneLoginSAML) PromptMFA() (int32, error)
Returns the deviceId of a MFA device that the user selects
func (*OneLoginSAML) SubmitMFA ¶
func (ols *OneLoginSAML) SubmitMFA(deviceId int32, appid uint32) (bool, error)
Handles sending the MFA code or Push MFA. Returns true/false if we got our Assertion
func (*OneLoginSAML) SubmitMFACode ¶
func (ols *OneLoginSAML) SubmitMFACode(app_id uint32, device_id int32, mfa_code int32) (bool, error)
Returns true/false if we got our assertion
type OneLoginStatus ¶
type OneLoginStatus struct {
Error bool `json:"error"`
Code uint16 `json:"code"`
Type string `json:"type"`
Message string `json:"message"`
}
Common Status response
type OneLoginUser ¶
type OneLoginUser struct {
Username string `json:"username"`
Email string `json:"email"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Id int64 `json:"id"`
}
Not used by this code, but is common to many other API calls
type RateLimit ¶
type RateLimit struct {
Status OneLoginStatus `json:"status"`
Data RateLimitData `json:"data"`
}
type RateLimitData ¶
type SAMLAssertion ¶
type SAMLInputOptions ¶
type SAMLResponse ¶
type SAMLResponse struct {
// successful response
Data string `json:"data"`
Message string `json:"message"`
User *OneLoginUser `json:"user"`
// Fields when we need MFA
StateToken string `json:"state_token"`
Devices []MfaDevice `json:"devices"`
CallbackUrl string `json:"callback_url"`
}
func (*SAMLResponse) NewMFA ¶
func (sr *SAMLResponse) NewMFA(o *OneLogin) *MFA