okta

package module
v0.0.0-...-e6abf21 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 9 Imported by: 11

README

Okta golang client

CircleCI

Basic Okta HTTP client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppLinks []struct {
	AppAssignmentID  string `json:"appAssignmentId"`
	AppInstanceID    string `json:"appInstanceId"`
	AppName          string `json:"appName"`
	CredentialsSetup bool   `json:"credentialsSetup"`
	Hidden           bool   `json:"hidden"`
	ID               string `json:"id"`
	Label            string `json:"label"`
	LinkURL          string `json:"linkUrl"`
	LogoURL          string `json:"logoUrl"`
	SortOrder        int64  `json:"sortOrder"`
}

type AuthnRequest

type AuthnRequest struct {
	Username   string `json:"username"`
	Password   string `json:"password"`
	RelayState string `json:"relayState"`
	Options    struct {
		MultiOptionalFactorEnroll bool `json:"multiOptionalFactorEnroll"`
		WarnBeforePasswordExpired bool `json:"warnBeforePasswordExpired"`
	} `json:"options"`
}

type AuthnResponse

type AuthnResponse struct {
	StateToken   string    `json:"stateToken"`
	ExpiresAt    time.Time `json:"expiresAt"`
	Status       string    `json:"status"`
	RelayState   string    `json:"relayState"`
	FactorResult string    `json:"factorResult"`
	SessionToken string    `json:"sessionToken"`
	Embedded     struct {
		User struct {
			ID              string    `json:"id"`
			PasswordChanged time.Time `json:"passwordChanged"`
			Profile         struct {
				Login     string `json:"login"`
				FirstName string `json:"firstName"`
				LastName  string `json:"lastName"`
				Locale    string `json:"locale"`
				TimeZone  string `json:"timeZone"`
			} `json:"profile"`
		} `json:"user"`
		Factors []Factor `json:"factors"`
		Policy  struct {
			AllowRememberDevice             bool `json:"allowRememberDevice"`
			RememberDeviceLifetimeInMinutes int  `json:"rememberDeviceLifetimeInMinutes"`
			RememberDeviceByDefault         bool `json:"rememberDeviceByDefault"`
		} `json:"policy"`
	} `json:"_embedded"`
	Links struct {
		Cancel struct {
			Href  string `json:"href"`
			Hints struct {
				Allow []string `json:"allow"`
			} `json:"hints"`
		} `json:"cancel"`
		Next struct {
			Name  string `json:"name"`
			Href  string `json:"href"`
			Hints struct {
				Allow []string `json:"allow"`
			} `json:"hints"`
		}
	} `json:"_links"`
}

func (*AuthnResponse) GetSupportedFactors

func (r *AuthnResponse) GetSupportedFactors() []Factor

type Client

type Client struct {
	Url           string
	ApiToken      string
	SessionCookie *http.Cookie
	// contains filtered or unexported fields
}

Client to access okta

func NewClient

func NewClient(org string) *Client

NewClient object for calling okta

func (c *Client) AppLinks(userID string, appName string) (*AppLinks, error)

func (*Client) Authenticate

func (c *Client) Authenticate(username, password string) (*AuthnResponse, error)

Authenticate with okta using username and password

func (*Client) Groups

func (c *Client) Groups(userID string) (*Groups, error)

Groups takes a user id and returns the groups the user belongs to

func (*Client) Session

func (c *Client) Session(sessionToken string) (*SessionResponse, error)

Session takes a session token and returns a session, the ID is stored as a cookie so it can be consumed by this library and its clients.

func (*Client) User

func (c *Client) User(userID string) (*User, error)

User takes a user id and returns data about that user

type ErrorResponse

type ErrorResponse struct {
	ErrorCode    string `json:"errorCode"`
	ErrorSummary string `json:"errorSummary"`
	ErrorLink    string `json:"errorLink"`
	ErrorID      string `json:"errorId"`
	ErrorCauses  []struct {
		ErrorSummary string `json:"errorSummary"`
	} `json:"errorCauses"`
}

type Factor

type Factor struct {
	ID         string `json:"id"`
	FactorType string `json:"factorType"`
	Provider   string `json:"provider"`
	VendorName string `json:"vendorName"`
	Profile    struct {
		CredentialID string `json:"credentialId"`
	} `json:"profile"`
	Links struct {
		Verify struct {
			Href  string `json:"href"`
			Hints struct {
				Allow []string `json:"allow"`
			} `json:"hints"`
		} `json:"verify"`
	} `json:"_links"`
}

func (Factor) VerifyPush

func (f Factor) VerifyPush(
	stateToken string,
	userAgent string,
	pollInterval time.Duration,
	pollTimeout time.Duration) (*AuthnResponse, error)

https://developer.okta.com/docs/api/resources/factors#verify-push-factor API diverges quite a bit from the API reference, this is the result of trial and error.

type Groups

type Groups []struct {
	ID      string `json:"id"`
	Profile struct {
		Name        string `json:"name"`
		Description string `json:"description"`
	} `json:"profile"`
}

type SessionRequest

type SessionRequest struct {
	SessionToken string `json:"sessionToken"`
}

type SessionResponse

type SessionResponse struct {
	ID                       string      `json:"id"`
	Login                    string      `json:"login"`
	UserID                   string      `json:"userId"`
	ExpiresAt                time.Time   `json:"expiresAt"`
	Status                   string      `json:"status"`
	LastPasswordVerification time.Time   `json:"lastPasswordVerification"`
	LastFactorVerification   interface{} `json:"lastFactorVerification"`
	Amr                      []string    `json:"amr"`
	Idp                      struct {
		ID   string `json:"id"`
		Type string `json:"type"`
	} `json:"idp"`
	MfaActive bool `json:"mfaActive"`
	Links     struct {
		Self struct {
			Href  string `json:"href"`
			Hints struct {
				Allow []string `json:"allow"`
			} `json:"hints"`
		} `json:"self"`
		Refresh struct {
			Href  string `json:"href"`
			Hints struct {
				Allow []string `json:"allow"`
			} `json:"hints"`
		} `json:"refresh"`
		User struct {
			Name  string `json:"name"`
			Href  string `json:"href"`
			Hints struct {
				Allow []string `json:"allow"`
			} `json:"hints"`
		} `json:"user"`
	} `json:"_links"`
}

type User

type User struct {
	ID              string     `json:"id"`
	Status          string     `json:"status"`
	Created         *time.Time `json:"created"`
	Activated       *time.Time `json:"activated"`
	StatusChanged   *time.Time `json:"statusChanged"`
	LastLogin       *time.Time `json:"lastLogin"`
	LastUpdated     *time.Time `json:"lastUpdated"`
	PasswordChanged *time.Time `json:"passwordChanged"`
	Profile         struct {
		Login             string `json:"login"`
		FirstName         string `json:"firstName"`
		LastName          string `json:"lastName"`
		NickName          string `json:"nickName"`
		DisplayName       string `json:"displayName"`
		Email             string `json:"email"`
		SecondEmail       string `json:"secondEmail"`
		ProfileURL        string `json:"profileUrl"`
		PreferredLanguage string `json:"preferredLanguage"`
		UserType          string `json:"userType"`
		Organization      string `json:"organization"`
		Title             string `json:"title"`
		Division          string `json:"division"`
		Department        string `json:"department"`
		CostCenter        string `json:"costCenter"`
		EmployeeNumber    string `json:"employeeNumber"`
		MobilePhone       string `json:"mobilePhone"`
		PrimaryPhone      string `json:"primaryPhone"`
		StreetAddress     string `json:"streetAddress"`
		City              string `json:"city"`
		State             string `json:"state"`
		ZipCode           string `json:"zipCode"`
		CountryCode       string `json:"countryCode"`
	} `json:"profile"`
	Credentials struct {
		Password struct {
		} `json:"password"`
		RecoveryQuestion struct {
			Question string `json:"question"`
		} `json:"recovery_question"`
		Provider struct {
			Type string `json:"type"`
			Name string `json:"name"`
		} `json:"provider"`
	} `json:"credentials"`
	Links struct {
		ResetPassword struct {
			Href string `json:"href"`
		} `json:"resetPassword"`
		ResetFactors struct {
			Href string `json:"href"`
		} `json:"resetFactors"`
		ExpirePassword struct {
			Href string `json:"href"`
		} `json:"expirePassword"`
		ForgotPassword struct {
			Href string `json:"href"`
		} `json:"forgotPassword"`
		ChangeRecoveryQuestion struct {
			Href string `json:"href"`
		} `json:"changeRecoveryQuestion"`
		Deactivate struct {
			Href string `json:"href"`
		} `json:"deactivate"`
		ChangePassword struct {
			Href string `json:"href"`
		} `json:"changePassword"`
	} `json:"_links"`
}

Jump to

Keyboard shortcuts

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