client

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: Apache-2.0 Imports: 24 Imported by: 3

README

Go API client for client

Moov AuthN is handles authentication of a user accessing the system. Its what starts the authentication flow thats required of all users to be able to get into the system. AuthN handles authentication up until theyt are matched to an identity. moov/identity handles matching up their authenticated credentials to their identity.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 0.0.1
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
go get github.com/antihax/optional

Put the package under your project folder and add the following in import:

import "./client"

Documentation for API Endpoints

All URIs are relative to https://local.moov.io:8202

Class Method HTTP request Description
AuthenticationApi AuthenticateWithProvider Get /authentication/providers/{providerID} Initiates the authentication with the Provider specified by `providerID`. This can have many possible responses depending on the specific provider being used.
AuthenticationApi FinishSignupFlow Post /authentication/signup Finalizes the signup flow and creates the new org.
AuthenticationApi FinishTenantFlow Post /authentication/tenants/{tenantID} Verifies and finishes the tenant login flow.
AuthenticationApi StartSignupFlow Get /authentication/signup Landing page to show moov signup page.
AuthenticationApi StartTenantFlow Get /authentication/tenants/{tenantID} Page that lists all the available providers that can be used to authenticate with that tenant.
CredentialsApi GetCredentials Get /credentials/{credentialID} Get a credential.
TenantsApi GetTenant Get /tenants/{tenantID}/authentication Returns details about the Tenant
TenantsApi ListTenants Get /tenants List the tenants available to the user under the credentials they used to sign in
TenantsApi UpdateTenant Put /tenants/{tenantID}/authentication Update details about a Tenant

Documentation For Models

Documentation For Authorization

GatewayAuth

  • Type: HTTP basic authentication

Example

auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
    UserName: "username",
    Password: "password",
})
r, err := client.Service.Operation(auth, args)

LoginAuth

  • Type: API key

Example

auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
    Key: "APIKEY",
    Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)

Author

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	AuthenticationApi *AuthenticationApiService

	CredentialsApi *CredentialsApiService

	TenantsApi *TenantsApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the AuthN API API v0.0.1 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

ChangeBasePath changes base path to allow switching to mocks

func (*APIClient) GetConfig

func (c *APIClient) GetConfig() *Configuration

Allow modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the OpenAPI operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

APIResponse stores the API response returned by the server.

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

NewAPIResponse returns a new APIResonse object.

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

NewAPIResponseWithError returns a new APIResponse object with the provided error message.

type AuthenticationApiService

type AuthenticationApiService service

AuthenticationApiService AuthenticationApi service

func (*AuthenticationApiService) AuthenticateWithProvider

func (a *AuthenticationApiService) AuthenticateWithProvider(ctx _context.Context, moovAuthn string, origin string, providerID string) (string, *_nethttp.Response, error)

AuthenticateWithProvider Initiates the authentication with the Provider specified by `providerID`. This can have many possible responses depending on the specific provider being used.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param moovAuthn
  • @param origin
  • @param providerID Name of the Provider to use which comes from the tenant config.

@return string

func (*AuthenticationApiService) FinishSignupFlow

func (a *AuthenticationApiService) FinishSignupFlow(ctx _context.Context, moovAuthn string, origin string, finishSignup FinishSignup) (string, *_nethttp.Response, error)

FinishSignupFlow Finalizes the signup flow and creates the new org.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param moovAuthn
  • @param origin
  • @param finishSignup Arguments needed register a user with OIDC credentials.

@return string

func (*AuthenticationApiService) FinishTenantFlow

func (a *AuthenticationApiService) FinishTenantFlow(ctx _context.Context, tenantID string) (string, *_nethttp.Response, error)

FinishTenantFlow Verifies and finishes the tenant login flow.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param tenantID Which tenant to log into.

@return string

func (*AuthenticationApiService) StartSignupFlow

StartSignupFlow Landing page to show moov signup page.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().

@return StartSignup

func (*AuthenticationApiService) StartTenantFlow

func (a *AuthenticationApiService) StartTenantFlow(ctx _context.Context, tenantID string) (SigninTenant, *_nethttp.Response, error)

StartTenantFlow Page that lists all the available providers that can be used to authenticate with that tenant.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param tenantID Which tenant to log into.

@return SigninTenant

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	Debug         bool              `json:"debug,omitempty"`
	Servers       []ServerConfiguration
	HTTPClient    *http.Client
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new Configuration object

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

AddDefaultHeader adds a new HTTP header to the default header in the request

func (*Configuration) ServerUrl

func (c *Configuration) ServerUrl(index int, variables map[string]string) (string, error)

ServerUrl returns URL based on server settings

type Credential

type Credential struct {
	// UUID v4
	CredentialID string `json:"credentialID,omitempty"`
	// OIDC provider that was used to handle authentication of this user.
	ProviderID string `json:"providerID,omitempty"`
	// ID of the remote OIDC server gives to this identity
	SubjectID string `json:"subjectID,omitempty"`
	// Email Address
	Email      string     `json:"email,omitempty"`
	CreatedOn  time.Time  `json:"createdOn,omitempty"`
	LastUsedOn time.Time  `json:"lastUsedOn,omitempty"`
	DisabledOn *time.Time `json:"disabledOn,omitempty"`
	// UUID v4
	DisabledBy *string `json:"disabledBy,omitempty"`
}

Credential Description of a successful OpenID connect credential

type CredentialsApiService

type CredentialsApiService service

CredentialsApiService CredentialsApi service

func (*CredentialsApiService) GetCredentials

func (a *CredentialsApiService) GetCredentials(ctx _context.Context, credentialID string) (Credential, *_nethttp.Response, error)

GetCredentials Get a credential.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param credentialID ID of the credential to disable

@return Credential

type FinishSignup

type FinishSignup struct {
	Identity SignupIdentity `json:"identity,omitempty"`
	Tenant   SignupTenant   `json:"tenant,omitempty"`
}

FinishSignup Returns the available login options for signing up

func (FinishSignup) Validate

func (a FinishSignup) Validate() error

type FinishSignupErrors

type FinishSignupErrors struct {
	Identity SignupIdentityErrors `json:"identity,omitempty"`
	Tenant   SignupTenantErrors   `json:"tenant,omitempty"`
}

FinishSignupErrors Returns the available login options for signing up

type GenericOpenAPIError

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

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type Provider

type Provider struct {
	// OIDC provider that was used to handle authentication of this user.
	ProviderID string `json:"providerID,omitempty"`
	// Descriptive name allowing spaces.
	Description string `json:"description,omitempty"`
	// Descriptive name allowing spaces.
	Service string `json:"service,omitempty"`
	Path    string `json:"path,omitempty"`
}

Provider Attributes about a provider that is used to login

type ServerConfiguration

type ServerConfiguration struct {
	Url         string
	Description string
	Variables   map[string]ServerVariable
}

ServerConfiguration stores the information about a server

type ServerVariable

type ServerVariable struct {
	Description  string
	DefaultValue string
	EnumValues   []string
}

ServerVariable stores the information about a server variable

type SigninTenant added in v0.2.3

type SigninTenant struct {
	// UUID v4
	TenantID string `json:"tenantID,omitempty"`
	// Descriptive name allowing spaces.
	Name      string     `json:"name,omitempty"`
	Alias     string     `json:"alias,omitempty"`
	Website   string     `json:"website,omitempty"`
	Providers []Provider `json:"providers,omitempty"`
}

SigninTenant Description of a tenant / organization including name and allowed providers.

type SignupIdentity

type SignupIdentity struct {
	FirstName string `json:"firstName,omitempty"`
	LastName  string `json:"lastName,omitempty"`
	// Email Address
	Email string `json:"email,omitempty"`
}

SignupIdentity Request to register a user in the system

func (SignupIdentity) Validate

func (a SignupIdentity) Validate() error

type SignupIdentityErrors

type SignupIdentityErrors struct {
	// Descriptive reason for failing validation
	FirstName string `json:"firstName,omitempty"`
	// Descriptive reason for failing validation
	LastName string `json:"lastName,omitempty"`
	// Descriptive reason for failing validation
	Email string `json:"email,omitempty"`
}

SignupIdentityErrors Request to register a user in the system

type SignupTenant

type SignupTenant struct {
	// Descriptive name allowing spaces.
	Name    string `json:"name,omitempty"`
	Alias   string `json:"alias,omitempty"`
	Website string `json:"website,omitempty"`
}

SignupTenant Description of a tenant / organization including name and allowed providers.

func (SignupTenant) Validate

func (a SignupTenant) Validate() error

type SignupTenantErrors

type SignupTenantErrors struct {
	// Descriptive reason for failing validation
	Name string `json:"name,omitempty"`
	// Descriptive reason for failing validation
	Alias string `json:"alias,omitempty"`
	// Descriptive reason for failing validation
	Website string `json:"website,omitempty"`
}

SignupTenantErrors Description of a tenant / organization including name and allowed providers.

type StartSignup

type StartSignup struct {
	Providers []Provider `json:"providers,omitempty"`
}

StartSignup Returns the available login options for signing up

type Tenant

type Tenant struct {
	// UUID v4
	TenantID  string    `json:"tenantID,omitempty"`
	CreatedOn time.Time `json:"createdOn,omitempty"`
	// UUID v4
	CreatedBy     string    `json:"createdBy,omitempty"`
	LastUpdatedOn time.Time `json:"lastUpdatedOn,omitempty"`
	// UUID v4
	LastUpdatedBy string `json:"lastUpdatedBy,omitempty"`
	// Descriptive name allowing spaces.
	Name      string   `json:"name,omitempty"`
	Alias     string   `json:"alias,omitempty"`
	Website   string   `json:"website,omitempty"`
	Providers []string `json:"providers,omitempty"`
}

Tenant Description of a tenant / organization including name and allowed providers.

type TenantsApiService added in v0.2.3

type TenantsApiService service

TenantsApiService TenantsApi service

func (*TenantsApiService) GetTenant added in v0.2.3

func (a *TenantsApiService) GetTenant(ctx _context.Context, tenantID string) (Tenant, *_nethttp.Response, error)

GetTenant Returns details about the Tenant

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param tenantID ID of the Tenant to lookup

@return Tenant

func (*TenantsApiService) ListTenants added in v0.2.3

func (a *TenantsApiService) ListTenants(ctx _context.Context) ([]Tenant, *_nethttp.Response, error)

ListTenants List the tenants available to the user under the credentials they used to sign in

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().

@return []Tenant

func (*TenantsApiService) UpdateTenant added in v0.2.3

func (a *TenantsApiService) UpdateTenant(ctx _context.Context, tenantID string, updateTenant UpdateTenant) (Tenant, *_nethttp.Response, error)

UpdateTenant Update details about a Tenant

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param tenantID ID of the Tenant to lookup
  • @param updateTenant Attributes about a tenant that to be updated.

@return Tenant

type UpdateTenant added in v0.2.3

type UpdateTenant struct {
	// Descriptive name allowing spaces.
	Name      string   `json:"name,omitempty"`
	Alias     string   `json:"alias,omitempty"`
	Website   string   `json:"website,omitempty"`
	Providers []string `json:"providers,omitempty"`
}

UpdateTenant Description of a tenant / organization including name and allowed providers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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