saidp_sdk_go

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

README

saidp-sdk-go

Go SDK for SecureAuth IdP API

saipd-sdk-go is a package that allows access to SecureAuth's REST api set. The goal of this package is to provide an easy and standard method to implement SecureAuth's API in a Go project.

The current SDK version 1.1.0 is written to support SecureAuth IdP 9.1 and newer.

This is a community driven project. If you would like to contribute, please fork and update. Changes will be reviewed then added to the project.

Requirements:

  • Go 1.8 or newer

Usage:

client, err := saidp_sdk_go.NewClient("af1b351845ec47968b27debd9cd4ce53", "101db0347fdf71dab63cd965b8782ff6ba0f8f1c91e8cf52f970d1267e0fb453", "company.secureauth.com", 443, SecureAuth1, true, false)
if err != nil {
    panic(err)
}
factors := new(Request)
factorResponse, err := factors.Get(client, "user")
if err != nil {
	panic(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AppID                string
	AppKey               string
	Host                 string
	Port                 int
	Realm                string
	SSL                  bool
	BypassCertValidation bool
}

Client : struct to hold configuration information for connecting to the SecureAuth APIs.

func NewClient

func NewClient(appID string, appKey string, host string, port int, realm string, ssl bool, bypassCert bool) (*Client, error)

NewClient :

Helper function to create a Client struct.

Parameters:

[Required] appId: SecureAuth API AppId.
[Required] appKey: SecureAuth API AppKey.
[Required] host: the host name (fully qualified/dns route-able) of the SecureAuth server.
[Required] port: the port that SecureAuth's web service is running on.
[Required] realm: the SecureAuth realm that will be serving the APIs.
[Required] ssl: if the SecureAuth realm/web service is running over ssl, set to true.
[Required] bypassCert: bypass certificate validation.

Returns:

Client: a pointer to a client struct with the supplied values.
Error: If an error is encountered, response will be nil and the error must be handled

func (Client) BuildEmptyPutRequest

func (c Client) BuildEmptyPutRequest(endpoint string) (*http.Request, error)

BuildEmptyPutRequest :

Function to supporting the building of put requests without content for each service package. Will handle signing and creation of the auth header as well as timestamp and other headers needed.

Parameters:

[Required] c: passing in the client containing authorization and host information.
[Required] endpoint: the api endpoint (after the SecureAuth# realm) that the get will be performed against.

Returns:

http.Request: Http Request struct that can be used via Http Client to make the request.
Error: If an error is encountered, response will be nil and the error must be handled.

func (Client) BuildGetRequest

func (c Client) BuildGetRequest(endpoint string) (*http.Request, error)

BuildGetRequest :

Function supporting the building of get requests for each service package. Will handle signing and creation of the auth header as well as timestamp and other headers needed.

Parameters:

[Required] c: passing in the client containing authorization and host information.
[Required] endpoint: the api endpoint (after the SecureAuth# realm) that the get will be performed against.

Returns:

http.Request: Http Request struct that can be used via Http Client to make the request.
Error: If an error is encountered, response will be nil and the error must be handled.

func (Client) BuildPostRequest

func (c Client) BuildPostRequest(endpoint string, content string) (*http.Request, error)

BuildPostRequest :

Function supporting the building of post requests for each service package. Will handle signing and creation of the auth header as well as timestamp and other headers needed.

Parameters:

[Required] c: passing in the client containing authorization and host information.
[Required] endpoint: the api endpoint (after the SecureAuth# realm) that the get will be performed against.
[Required] content: the json content to be posted to the api endpoint.

Returns:

http.Request: Http Request struct that can be used via Http Client to make the request.
Error: If an error is encountered, response will be nil and the error must be handled.

func (Client) BuildPutRequest

func (c Client) BuildPutRequest(endpoint string, content string) (*http.Request, error)

BuildPutRequest :

Function supporting the building of put requests for each service package. Will handle signing and creation of the auth header as well as timestamp and other headers needed.

Parameters:

[Required] c: passing in the client containing authorization and host information.
[Required] endpoint: the api endpoint (after the SecureAuth# realm) that the get will be performed against.
[Required] content: the json content to be put to the api endpoint.

Returns:

http.Request: Http Request struct that can be used via Http Client to make the request.
Error: If an error is encountered, response will be nil and the error must be handled.

func (Client) Do

func (c Client) Do(req *http.Request) (*http.Response, error)

Do :

Function to execute a Http Request.

Parameters:

[Required] c: passing in the client containing authorization and host information.
[Required] req: http.Request struct to execute.

Returns:

http.Response: Http Response struct that can be used to get the body for the api response.
Error: If an error is encountered, response will be nil and the error must be handled.

func (Client) Sign

func (c Client) Sign(method string, endpoint string, content string) (string, error)

Sign :

Function to create the Authorization headed needed to perform API calls to SecureAuth.

Parameters:

[Required] c: passing in the client containing authorization and host information.
[Required] method: the http verb of the method being used (GET, POST, PUT)
[Required] endpoint: the api endpoint (after the SecureAuth# realm) that the get will be performed against.
content: the json content to be put to the api endpoint.

Returns:

string: Authorization header string.
Error: If an error is encountered, response will be nil and the error must be handled.

type HTTPError added in v1.1.0

type HTTPError struct {
	Status     string `json:"status,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       int    `json:",omitempty"`
	StatusText string `json:",omitempty"`
}

HTTPError : struct to hold error message status for proper handling.

Directories

Path Synopsis
services
dfp
otp
utilities

Jump to

Keyboard shortcuts

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