okta

package
v1.13.9 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserNotFound = errors.New("user not found")

ErrUserNotFound is returned when a user is not present in Okta.

Functions

This section is empty.

Types

type BoocsekAttributes added in v1.12.0

type BoocsekAttributes struct {
	Site        string   `json:"site"`
	Position    string   `json:"position"`
	Channel     string   `json:"channel"`
	Tier        string   `json:"tier"`
	Team        string   `json:"team"`
	TeamManager string   `json:"teamManager"`
	Staff       string   `json:"staff"`
	State       string   `json:"state"`
	KiwibaseID  int32    `json:"kiwibaseId"`
	Substate    string   `json:"substate"`
	Skills      []string `json:"skills"`
}

BoocsekAttributes contains formatted Boocsek attributes provided by Okta.

type Cacher

type Cacher interface {
	Get(key string, value interface{}) error
	Set(key string, value interface{}, ttl time.Duration) error
	Del(key string) error
	MSet(pairs map[string]interface{}, ttl time.Duration) error
}

Cacher contains methods needed from a cache.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represent an Okta client.

func NewClient

func NewClient(opts *ClientOpts) *Client

NewClient creates an Okta client based on the given options.

func (*Client) AddPermissions

func (c *Client) AddPermissions(user *User, service string) error

AddPermissions adds Okta groups to the given user object.

func (*Client) GetGroups

func (c *Client) GetGroups() ([]Group, error)

GetGroups retrieves Okta groups.

func (*Client) GetUser

func (c *Client) GetUser(email string) (User, error)

GetUser returns an Okta user by email. It first tries to get it from cache, and if not present there, it will fetch it from Okta API.

func (*Client) SyncGroups

func (c *Client) SyncGroups()

SyncGroups gets all groups from Okta and saves them into cache.

func (*Client) SyncUsers

func (c *Client) SyncUsers()

SyncUsers gets all users from Okta and saves them into cache.

type ClientOpts

type ClientOpts struct {
	Cache         Cacher
	LockManager   *storage.LockManager
	BaseURL       string
	AuthToken     string
	IAMConfig     *cfg.ServiceConfig
	Metrics       *monitoring.Metrics
	CustomFetcher func(userAgent string, metrics *monitoring.Metrics) Fetcher
}

ClientOpts contains options to create an Okta client.

type Fetcher

type Fetcher func(req Request) (*Response, error)

Fetcher is a function used to send HTTP requests.

type Group

type Group struct {
	ID                    string    `json:"id"`
	Name                  string    `json:"name"`
	Description           string    `json:"description"`
	LastMembershipUpdated time.Time `json:"lastMembershipUpdated"`
}

Group represents an Okta group.

type GroupMembership

type GroupMembership struct {
	GroupID   string
	GroupName string
	Users     []string
}

GroupMembership holds the current user ids for users who are part of a given group.

type Request

type Request struct {
	Method string
	URL    string
	Token  string
	Body   io.Reader
}

Request contains options for an HTTP request created using shared.Fetch.

type Response

type Response struct {
	*http.Response
}

Response for an HTTP request, exposes a JSON method to get the retrieved data.

func (Response) JSON

func (res Response) JSON(body interface{}) error

JSON retrieves data from HTTP response and store it in the struct pointed by `body` (note: `body` should be a pointer to the struct you expect the HTTP call to return).

func (Response) String

func (res Response) String() (string, error)

String reads data from HTTP response and returns it in the form of a string.

type User

type User struct {
	OktaID                string            `json:"oktaId,omitempty"` // Exported to be cache-able
	EmployeeNumber        string            `json:"employeeNumber"`
	FirstName             string            `json:"firstName"`
	LastName              string            `json:"lastName"`
	Position              string            `json:"position"`
	Department            string            `json:"department"`
	Email                 string            `json:"email"`
	Location              string            `json:"location"`
	IsVendor              bool              `json:"isVendor"`
	TeamMembership        []string          `json:"teamMembership"` // Deprecated
	OrganizationStructure string            `json:"orgStructure"`
	GroupMembership       []Group           `json:"groupMembership,omitempty"`
	Manager               string            `json:"manager"`
	Permissions           []string          `json:"permissions"`
	BoocsekAttributes     BoocsekAttributes `json:"boocsek"`
}

User contains formatted user data provided by Okta.

Jump to

Keyboard shortcuts

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