onelogin

package
v0.0.0-...-416c7cc Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/.

* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/.

* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/.

Index

Constants

View Source
const (

	// GenerateSamlAssertionPath - OneLogin API endpoint to generate a SAML assertions
	GenerateSamlAssertionPath string = "/api/2/saml_assertion"

	// GenerateTokensPath - OneLogin API endpoint to generate an access token and refresh token
	GenerateTokensPath string = "/auth/oauth2/v2/token"

	// GetUserByEmailPath - OneLogin API endpoint to get a paginated list of users via email address
	GetUserByEmailPath string = "/api/2/users?email=%s"

	// VerifyFactorPath - OneLogin API endpoint to verify a one-time password (OTP) value
	VerifyFactorPath string = "/api/2/saml_assertion/verify_factor"
)
View Source
const (
	// MFADeviceOneLoginProtect symbolizes the OneLogin Protect mobile app, which supports push
	// notifications. More info here: https://developers.onelogin.com/api-docs/1/saml-assertions/verify-factor
	MFADeviceOneLoginProtect = "OneLogin Protect"

	// MFAPushTimeout represents the number of seconds to wait for a successful push attempt before
	// falling back to OTP input.
	MFAPushTimeout = 30

	// MFAInterval represents the interval at which we check for an accepted push message.
	MFAInterval = 1
)

Variables

This section is empty.

Functions

func Get

func Get(app, provider, pArn, awsRegion string, duration int32) (*aws.Credentials, error)

Get gets temporary credentials for the given app. TODO Move AWS logic outside this function.

Types

type Client

type Client struct {
	http.Client
	Endpoints Endpoints
}

Client represents a OneLogin API client.

func NewClient

func NewClient(region string) (c *Client, err error)

NewClient creates a new Client and returns a pointer to it.

func (*Client) GenerateSamlAssertion

func (c *Client) GenerateSamlAssertion(token string, p *GenerateSamlAssertionParams) (*GenerateSamlAssertionResponse, error)

GenerateSamlAssertion gets a OneLogin access token and a GenerateSamlAssertionParams struct and returns a GenerateSamlAssertionResponse. TODO improve doc

func (*Client) GenerateTokens

func (c *Client) GenerateTokens(clientID, clientSecret string) (string, error)

GenerateTokens generates the tokens required for interacting with the OneLogin API.

func (*Client) VerifyFactor

func (c *Client) VerifyFactor(token string, p *VerifyFactorParams) (*VerifyFactorResponse, error)

VerifyFactor gets a OneLogin access token and a VerifyFactorParams struct and returns a VerifyFactorResponse.

type Device

type Device struct {
	DeviceID   int    `json:"device_id"`
	DeviceType string `json:"device_type"`
}

type Endpoints

type Endpoints struct {
	Region string
	// contains filtered or unexported fields
}

Endpoints represent the OneLogin API HTTP endpoints.

func (Endpoints) GenerateSamlAssertion

func (e Endpoints) GenerateSamlAssertion() string

GenerateSamlAssertion will return a the relevant Generate SAML Assertion endpoint for a given base URL

func (Endpoints) GenerateTokens

func (e Endpoints) GenerateTokens() string

GenerateTokens will return the relevant Generate Tokens endpoint for a base URL

func (Endpoints) GetUserByEmail

func (e Endpoints) GetUserByEmail(email string) string

GetUserByEmail will, given an email address, return a valid url to search the Users endpoint by email address

func (Endpoints) VerifyFactor

func (e Endpoints) VerifyFactor() string

VerifyFactor will return a valid URL for requests to check MFA tokens

type GenerateSamlAssertionParams

type GenerateSamlAssertionParams struct {
	UsernameOrEmail string `json:"username_or_email"`
	Password        string `json:"password"`
	AppId           string `json:"app_id"`
	Subdomain       string `json:"subdomain"`
}

type GenerateSamlAssertionResponse

type GenerateSamlAssertionResponse struct {
	StateToken  string `json:"state_token"`
	Message     string `json:"message"`
	Devices     []Device
	CallbackURL string `json:"callback_url"`
	User        struct {
		Lastname  string `json:"lastname"`
		Username  string `json:"username"`
		Email     string `json:"email"`
		Firstname string `json:"firstname"`
		ID        int    `json:"id"`
	}
	Data string `json:"data"`
}

TODO This one assumes MFA is enabled. Need to handle all cases.

type GenerateTokensParams

type GenerateTokensParams struct {
	GrantType string `json:"grant_type"`
}

type GenerateTokensResponse

type GenerateTokensResponse struct {
	AccessToken  string    `json:"access_token"`
	CreatedAt    time.Time `json:"created_at"`
	ExpiresIn    int       `json:"expires_in"`
	RefreshToken string    `json:"refresh_token"`
	TokenType    string    `json:"token_type"`
	AccountID    int       `json:"account_id"`
}

type GetUserByEmailResponse

type GetUserByEmailResponse struct {
	Status struct {
		Error   bool   `json:"error"`
		Code    int    `json:"code"`
		Type    string `json:"type"`
		Message string `json:"message"`
	} `json:"status"`
	Data []struct {
		ID int `json:"id"`
	}
}

type VerifyFactorParams

type VerifyFactorParams struct {
	AppId       string `json:"app_id"`
	DeviceId    string `json:"device_id"`
	StateToken  string `json:"state_token"`
	OtpToken    string `json:"otp_token"`
	DoNotNotify bool   `json:"do_not_notify"`
}

type VerifyFactorResponse

type VerifyFactorResponse struct {
	Message string `json:"message"`
	Data    string `json:"data"`
}

Jump to

Keyboard shortcuts

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