admin

package
v0.0.0-...-ae8b995 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPhonesExtension

func GetPhonesExtension(ext string) func(*url.Values)

GetPhonesExtension sets the optional extension parameter for a GetPhones request.

func GetPhonesNumber

func GetPhonesNumber(number string) func(*url.Values)

GetPhonesNumber sets the optional number parameter for a GetPhones request.

func GetTokensTypeAndSerial

func GetTokensTypeAndSerial(typ, serial string) func(*url.Values)

GetTokensTypeAndSerial sets the optional type and serial parameters for a GetTokens request.

func GetUsersUsername

func GetUsersUsername(name string) func(*url.Values)

GetUsersUsername sets the optional username parameter for a GetUsers request.

func Limit

func Limit(limit uint64) func(*url.Values)

Limit sets the optional limit parameter for an API request.

func Offset

func Offset(offset uint64) func(*url.Values)

Offset sets the optional offset parameter for an API request.

Types

type AdminLog

type AdminLog map[string]interface{}

An AdminLog retrieved from https://duo.com/docs/adminapi#administrator-logs TODO: @Duo update this to be a struct based on the returned JSON structure of an admin log.

func (AdminLog) Timestamp

func (log AdminLog) Timestamp() (time.Time, error)

Timestamp parses and coerces the timestamp value of the log.

type AdminLogList

type AdminLogList []AdminLog

An AdminLogList holds log entries and provides functionality used for pagination.

func (AdminLogList) GetNextOffset

func (logs AdminLogList) GetNextOffset(maxtime time.Time) func(params *url.Values)

GetNextOffset uses log timestamps to return an option that will configure a request to fetch the next page of logs. It returns nil when no more logs can be fetched.

type AdminLogResult

type AdminLogResult struct {
	duoapi.StatResult
	Logs AdminLogList `json:"response"`
}

AdminLogResult is the structured JSON result of GetAdminLogs (for the V1 API).

type AuthLog

type AuthLog map[string]interface{}

An AuthLog retrieved from https://duo.com/docs/adminapi#authentication-logs TODO: @Duo update this to be a struct based on the returned JSON structure of an authentication log.

type AuthLogList

type AuthLogList struct {
	Metadata LogListV2Metadata `json:"metadata"`
	Logs     []AuthLog         `json:"authlogs"`
}

An AuthLogList holds retreived logs and V2 metadata used for pagination.

type AuthLogResult

type AuthLogResult struct {
	duoapi.StatResult
	Response AuthLogList `json:"response"`
}

AuthLogResult is the structured JSON result of GetAuthLogs (for the V2 API).

type Client

type Client struct {
	duoapi.DuoApi
}

Client provides access to Duo's admin API.

func New

func New(base duoapi.DuoApi) *Client

New initializes an admin API Client struct.

func (*Client) AssociateUserToken

func (c *Client) AssociateUserToken(userID, tokenID string) (*StringResult, error)

AssociateUserToken calls POST /admin/v1/users/:user_id/tokens See https://duo.com/docs/adminapi#associate-hardware-token-with-user

func (*Client) GetAdminLogs

func (c *Client) GetAdminLogs(mintime time.Time, options ...func(*url.Values)) (*AdminLogResult, error)

GetAdminLogs retrieves a page of admin logs with timestamps starting at mintime. It relies on the option provided by AdminLogResult.Logs.GetNextOffset() for pagination. Calls GET /admin/v1/logs/administrator See https://duo.com/docs/adminapi#administrator-logs

func (*Client) GetAuthLogs

func (c *Client) GetAuthLogs(mintime time.Time, window time.Duration, options ...func(*url.Values)) (*AuthLogResult, error)

GetAuthLogs retrieves a page of authentication logs within the time range starting at mintime and ending at mintime + window. It relies on the option provided by AuthLogResult.Metadata.GetNextOffset() for pagination. Calls GET /admin/v2/logs/authentication See https://duo.com/docs/adminapi#authentication-logs

func (*Client) GetGroup

func (c *Client) GetGroup(groupID string) (*GetGroupResult, error)

GetGroup calls GET /admin/v2/group/:group_id See https://duo.com/docs/adminapi#get-group-info

func (*Client) GetGroups

func (c *Client) GetGroups(options ...func(*url.Values)) (*GetGroupsResult, error)

GetGroups calls GET /admin/v1/groups See https://duo.com/docs/adminapi#retrieve-groups

func (*Client) GetPhone

func (c *Client) GetPhone(phoneID string) (*GetPhoneResult, error)

GetPhone calls GET /admin/v1/phones/:phone_id See https://duo.com/docs/adminapi#retrieve-phone-by-id

func (*Client) GetPhones

func (c *Client) GetPhones(options ...func(*url.Values)) (*GetPhonesResult, error)

GetPhones calls GET /admin/v1/phones See https://duo.com/docs/adminapi#phones

func (*Client) GetTelephonyLogs

func (c *Client) GetTelephonyLogs(mintime time.Time, options ...func(*url.Values)) (*TelephonyLogResult, error)

GetTelephonyLogs retrieves a page of telephony logs with timestamps starting at mintime. It relies on the option provided by TelephonyLogResult.Logs.GetNextOffset() for pagination. Calls GET /admin/v1/logs/telephony See https://duo.com/docs/adminapi#telephony-logs

func (*Client) GetToken

func (c *Client) GetToken(tokenID string) (*GetTokenResult, error)

GetToken calls GET /admin/v1/tokens/:token_id See https://duo.com/docs/adminapi#retrieve-hardware-tokens

func (*Client) GetTokens

func (c *Client) GetTokens(options ...func(*url.Values)) (*GetTokensResult, error)

GetTokens calls GET /admin/v1/tokens See https://duo.com/docs/adminapi#retrieve-hardware-tokens

func (*Client) GetU2FToken

func (c *Client) GetU2FToken(registrationID string) (*GetU2FTokensResult, error)

GetU2FToken calls GET /admin/v1/u2ftokens/:registration_id See https://duo.com/docs/adminapi#retrieve-u2f-token-by-id

func (*Client) GetU2FTokens

func (c *Client) GetU2FTokens(options ...func(*url.Values)) (*GetU2FTokensResult, error)

GetU2FTokens calls GET /admin/v1/u2ftokens See https://duo.com/docs/adminapi#retrieve-u2f-tokens

func (*Client) GetUser

func (c *Client) GetUser(userID string) (*GetUserResult, error)

GetUser calls GET /admin/v1/users/:user_id See https://duo.com/docs/adminapi#retrieve-user-by-id

func (*Client) GetUserGroups

func (c *Client) GetUserGroups(userID string, options ...func(*url.Values)) (*GetGroupsResult, error)

GetUserGroups calls GET /admin/v1/users/:user_id/groups See https://duo.com/docs/adminapi#retrieve-groups-by-user-id

func (*Client) GetUserPhones

func (c *Client) GetUserPhones(userID string, options ...func(*url.Values)) (*GetPhonesResult, error)

GetUserPhones calls GET /admin/v1/users/:user_id/phones See https://duo.com/docs/adminapi#retrieve-phones-by-user-id

func (*Client) GetUserTokens

func (c *Client) GetUserTokens(userID string, options ...func(*url.Values)) (*GetTokensResult, error)

GetUserTokens calls GET /admin/v1/users/:user_id/tokens See https://duo.com/docs/adminapi#retrieve-hardware-tokens-by-user-id

func (*Client) GetUserU2FTokens

func (c *Client) GetUserU2FTokens(userID string, options ...func(*url.Values)) (*GetU2FTokensResult, error)

GetUserU2FTokens calls GET /admin/v1/users/:user_id/u2ftokens See https://duo.com/docs/adminapi#retrieve-u2f-tokens-by-user-id

func (*Client) GetUsers

func (c *Client) GetUsers(options ...func(*url.Values)) (*GetUsersResult, error)

GetUsers calls GET /admin/v1/users See https://duo.com/docs/adminapi#retrieve-users

type GetGroupResult

type GetGroupResult struct {
	duoapi.StatResult
	Response Group
}

GetGroupResult models responses containing a single group.

type GetGroupsResult

type GetGroupsResult struct {
	duoapi.StatResult
	ListResult
	Response []Group
}

GetGroupsResult models responses containing a list of groups.

type GetPhoneResult

type GetPhoneResult struct {
	duoapi.StatResult
	Response Phone
}

GetPhoneResult models responses containing a single phone.

type GetPhonesResult

type GetPhonesResult struct {
	duoapi.StatResult
	ListResult
	Response []Phone
}

GetPhonesResult models responses containing a list of phones.

type GetTokenResult

type GetTokenResult struct {
	duoapi.StatResult
	Response Token
}

GetTokenResult models responses containing a single token.

type GetTokensResult

type GetTokensResult struct {
	duoapi.StatResult
	ListResult
	Response []Token
}

GetTokensResult models responses containing a list of tokens.

type GetU2FTokensResult

type GetU2FTokensResult struct {
	duoapi.StatResult
	ListResult
	Response []U2FToken
}

GetU2FTokensResult models responses containing a list of U2F tokens.

type GetUserResult

type GetUserResult struct {
	duoapi.StatResult
	Response User
}

GetUserResult models responses containing a single user.

type GetUsersResult

type GetUsersResult struct {
	duoapi.StatResult
	ListResult
	Response []User
}

GetUsersResult models responses containing a list of users.

type Group

type Group struct {
	Desc             string
	GroupID          string `json:"group_id"`
	MobileOTPEnabled bool   `json:"mobile_otp_enabled"`
	Name             string
	PushEnabled      bool `json:"push_enabled"`
	SMSEnabled       bool `json:"sms_enabled"`
	Status           string
	VoiceEnabled     bool `json:"voice_enabled"`
}

Group models a group to which users may belong.

type ListResult

type ListResult struct {
	Metadata ListResultMetadata `json:"metadata"`
}

type ListResultMetadata

type ListResultMetadata struct {
	NextOffset   json.Number `json:"next_offset"`
	PrevOffset   json.Number `json:"prev_offset"`
	TotalObjects json.Number `json:"total_objects"`
}

type LogListV2Metadata

type LogListV2Metadata struct {
	NextOffset []string `json:"next_offset"`
}

LogListV2Metadata holds pagination metadata for API V2 log endpoints.

func (LogListV2Metadata) GetNextOffset

func (metadata LogListV2Metadata) GetNextOffset() func(params *url.Values)

GetNextOffset uses response metadata to return an option that will configure a request to fetch the next page of logs. It returns nil when no more logs can be fetched.

type Phone

type Phone struct {
	Activated        bool
	Capabilities     []string
	Encrypted        string
	Extension        string
	Fingerprint      string
	Name             string
	Number           string
	PhoneID          string `json:"phone_id"`
	Platform         string
	Postdelay        string
	Predelay         string
	Screenlock       string
	SMSPasscodesSent bool
	Type             string
	Users            []User
}

Phone models a user's phone.

type StringResult

type StringResult struct {
	duoapi.StatResult
	Response string
}

StringResult models responses containing a simple string.

type TelephonyLog

type TelephonyLog map[string]interface{}

A TelephonyLog retrieved from https://duo.com/docs/adminapi#telephony-logs TODO: @Duo update this to be a struct based on the returned JSON structure of a telephony log.

func (TelephonyLog) Timestamp

func (log TelephonyLog) Timestamp() (time.Time, error)

Timestamp parses and coerces the timestamp value of the log.

type TelephonyLogList

type TelephonyLogList []TelephonyLog

An TelephonyLogList holds log entries and provides functionality used for pagination.

func (TelephonyLogList) GetNextOffset

func (logs TelephonyLogList) GetNextOffset(maxtime time.Time) func(params *url.Values)

GetNextOffset uses log timestamps to return an option that will configure a request to fetch the next page of logs. It returns nil when no more logs can be fetched.

type TelephonyLogResult

type TelephonyLogResult struct {
	duoapi.StatResult
	Logs TelephonyLogList `json:"response"`
}

TelephonyLogResult is the structured JSON result of GetTelephonyLogs (for the V1 API).

type Token

type Token struct {
	TokenID  string `json:"token_id"`
	Type     string
	Serial   string
	TOTPStep *int `json:"totp_step"`
	Users    []User
}

Token models a hardware security token.

type U2FToken

type U2FToken struct {
	DateAdded      uint64 `json:"date_added"`
	RegistrationID string `json:"registration_id"`
	User           *User
}

U2FToken models a U2F security token.

type User

type User struct {
	Alias1            *string
	Alias2            *string
	Alias3            *string
	Alias4            *string
	Created           uint64
	Email             string
	FirstName         *string
	Groups            []Group
	LastDirectorySync *uint64 `json:"last_directory_sync"`
	LastLogin         *uint64 `json:"last_login"`
	LastName          *string
	Notes             string
	Phones            []Phone
	RealName          *string
	Status            string
	Tokens            []Token
	UserID            string `json:"user_id"`
	Username          string
}

User models a single user.

Jump to

Keyboard shortcuts

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