duoapi

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

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

Go to latest
Published: Apr 8, 2024 License: BSD-3-Clause Imports: 16 Imported by: 124

README

Overview

Build Status Issues Forks Stars License

duo_api_golang - Go language bindings for the Duo APIs (both auth and admin).

TLS 1.2 and 1.3 Support

Duo_api_golang uses the Go cryptography library for TLS operations. Go versions 1.13 and higher support both TLS 1.2 and 1.3.

Duo Auth API

The Auth API is a low-level, RESTful API for adding strong two-factor authentication to your website or application.

This module's API client implementation is complete; corresponding methods are exported for all available endpoints.

For more information see the Auth API guide.

Duo Admin API

The Admin API provides programmatic access to the administrative functionality of Duo Security's two-factor authentication platform.

This module's API client implementation is incomplete; methods for fetching most entity types are exported, but methods that modify entities have (mostly) not yet been implemented. PRs welcome!

For more information see the Admin API guide.

Testing

$ go test -v -race ./...

Linting

$ gofmt -d .

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetInsecure

func SetInsecure() func(*apiOptions)

Optional parameter for testing only. Bypasses all TLS certificate validation.

func SetProxy

func SetProxy(proxy func(*http.Request) (*url.URL, error)) func(*apiOptions)

Optional parameter for NewDuoApi, used to configure an HTTP Connect proxy server for all outbound communications.

func SetTimeout

func SetTimeout(timeout time.Duration) func(*apiOptions)

Optional parameter for NewDuoApi, used to configure timeouts on API calls.

func SetTransport

func SetTransport(transport func(*http.Transport)) func(*apiOptions)

SetTransport enables additional control over the HTTP transport used to connect to the Duo API.

func UseTimeout

func UseTimeout(opts *requestOptions)

Pass to Request or SignedRequest to configure a timeout on the request

Types

type DuoApi

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

func NewDuoApi

func NewDuoApi(ikey string,
	skey string,
	host string,
	userAgent string,
	options ...func(*apiOptions)) *DuoApi

Build an return a DuoApi struct. ikey is your Duo integration key skey is your Duo integration secret key host is your Duo host userAgent allows you to specify the user agent string used when making the web request to Duo. Information about the client will be appended to the userAgent. options are optional parameters. Use SetTimeout() to specify a timeout value for Rest API calls. Use SetProxy() to specify proxy settings for Duo API calls.

Example: duoapi.NewDuoApi(ikey,skey,host,userAgent,duoapi.SetTimeout(10*time.Second))

func (*DuoApi) Call

func (duoapi *DuoApi) Call(method string,
	uri string,
	params url.Values,
	options ...DuoApiOption) (*http.Response, []byte, error)

Make an unsigned Duo Rest API call. See Duo's online documentation for the available REST API's. method is POST or GET uri is the URI of the Duo Rest call params HTTP query parameters to include in the call. options Optional parameters. Use UseTimeout to toggle whether the Duo Rest API call should timeout or not.

Example: duo.Call("GET", "/auth/v2/ping", nil, duoapi.UseTimeout)

func (*DuoApi) JSONSignedCall

func (duoapi *DuoApi) JSONSignedCall(method string,
	uri string,
	params JSONParams,
	options ...DuoApiOption) (*http.Response, []byte, error)

Make a signed Duo Rest API call that takes JSON as an argument. See Duo's online documentation for the available REST API's. method is one of GET, POST, PATCH, PUT, DELETE uri is the URI of the Duo Rest call json is the JSON parameters to include in the call. options Optional parameters. Use UseTimeout to toggle whether the Duo Rest API call should timeout or not.

Example:
params := duoapi.JSONParams{
	"user_id":         userid,
	"activation_code": activationCode,
}
JSONSignedCall("POST", "/auth/v2/enroll_status", params, duoapi.UseTimeout)

func (*DuoApi) SetCustomHTTPClient

func (duoapi *DuoApi) SetCustomHTTPClient(c *http.Client)

SetCustomHTTPClient allows one to set a completely custom http client that will be used to make network calls to the duo api

func (*DuoApi) SignedCall

func (duoapi *DuoApi) SignedCall(method string,
	uri string,
	params url.Values,
	options ...DuoApiOption) (*http.Response, []byte, error)

Make a signed Duo Rest API call. See Duo's online documentation for the available REST API's. method is POST or GET uri is the URI of the Duo Rest call params HTTP query parameters to include in the call. options Optional parameters. Use UseTimeout to toggle whether the Duo Rest API call should timeout or not.

Example: duo.SignedCall("GET", "/auth/v2/check", nil, duoapi.UseTimeout)

type DuoApiOption

type DuoApiOption func(*requestOptions)

type JSONParams

type JSONParams map[string]interface{}

type StatResult

type StatResult struct {
	Stat           string
	Code           *int32
	Message        *string
	Message_Detail *string
}

API calls will return a StatResult object. On success, Stat is 'OK'. On error, Stat is 'FAIL', and Code, Message, and Message_Detail contain error information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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