api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ValidateEvent constant
	ValidateEvent = "validate"
	// SignupEvent constant
	SignupEvent = "signup"
	// LoginEvent constant
	LoginEvent = "login"
)

Variables

This section is empty.

Functions

func SafeHTTPClient

func SafeHTTPClient(client *http.Client, log logrus.FieldLogger) *http.Client

SafeHTTPClient returns a roundtripper client

func SafeRoundtripper

func SafeRoundtripper(trans http.RoundTripper, log logrus.FieldLogger) http.RoundTripper

SafeRoundtripper creates a new roundtripper

func WithInstanceConfig

func WithInstanceConfig(ctx context.Context, config *conf.Configuration, instanceID uuid.UUID) (context.Context, error)

WithInstanceConfig creates a new ctx with a config

Types

type API

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

API is the main REST API

func NewAPI

func NewAPI(globalConfig *conf.GlobalConfiguration, db *storage.Connection) *API

NewAPI instantiates a new REST API

func NewAPIFromConfigFile

func NewAPIFromConfigFile(filename string, version string) (*API, *conf.Configuration, error)

NewAPIFromConfigFile creates a new REST API using the provided configuration file.

func NewAPIWithVersion

func NewAPIWithVersion(ctx context.Context, globalConfig *conf.GlobalConfiguration, db *storage.Connection, version string) *API

NewAPIWithVersion creates a new REST API using the specified version

func (*API) CreateInstance

func (a *API) CreateInstance(w http.ResponseWriter, r *http.Request) error

CreateInstance creates a new instance

func (*API) DeleteInstance

func (a *API) DeleteInstance(w http.ResponseWriter, r *http.Request) error

DeleteInstance deletes a instance

func (*API) ExternalProviderCallback

func (a *API) ExternalProviderCallback(w http.ResponseWriter, r *http.Request) error

ExternalProviderCallback maps redirectErrors

func (*API) ExternalProviderRedirect

func (a *API) ExternalProviderRedirect(w http.ResponseWriter, r *http.Request) error

ExternalProviderRedirect redirects to external provider for login and creates a new claim

func (*API) GetAppManifest

func (a *API) GetAppManifest(w http.ResponseWriter, r *http.Request) error

GetAppManifest returns the version and details about the service

func (*API) GetInstance

func (a *API) GetInstance(w http.ResponseWriter, r *http.Request) error

GetInstance returns an instance

func (*API) HealthCheck

func (a *API) HealthCheck(w http.ResponseWriter, r *http.Request) error

HealthCheck returns a "is a live"

func (*API) Invite

func (a *API) Invite(w http.ResponseWriter, r *http.Request) error

Invite is the endpoint for inviting a new user

func (*API) ListenAndServe

func (a *API) ListenAndServe(hostAndPort string)

ListenAndServe starts the REST API

func (*API) Logout

func (a *API) Logout(w http.ResponseWriter, r *http.Request) error

Logout is the endpoint for logging out a user and thereby revoking any refresh tokens

func (*API) Mailer

func (a *API) Mailer(ctx context.Context) mailer.Mailer

Mailer creates a new Mailer with config

func (*API) OAuthProvider

func (a *API) OAuthProvider(ctx context.Context, name string) (provider.OAuthProvider, error)

OAuthProvider validates a oauth provider

func (*API) Provider

func (a *API) Provider(ctx context.Context, name string) (provider.Provider, error)

Provider returns a Provider interface for the given name.

func (*API) Recover

func (a *API) Recover(w http.ResponseWriter, r *http.Request) error

Recover sends a recovery email

func (*API) RefreshTokenGrant

func (a *API) RefreshTokenGrant(ctx context.Context, w http.ResponseWriter, r *http.Request) error

RefreshTokenGrant implements the refresh_token grant type flow

func (*API) ResourceOwnerPasswordGrant

func (a *API) ResourceOwnerPasswordGrant(ctx context.Context, w http.ResponseWriter, r *http.Request) error

ResourceOwnerPasswordGrant implements the password grant type flow

func (*API) SAMLMetadata

func (a *API) SAMLMetadata(w http.ResponseWriter, r *http.Request) error

SAMLMetadata creates a new provider and writes metadata

func (*API) Settings

func (a *API) Settings(w http.ResponseWriter, r *http.Request) error

Settings returns the current IDentity provider settings

func (*API) Signup

func (a *API) Signup(w http.ResponseWriter, r *http.Request) error

Signup is the endpoint for registering a new user

func (*API) Token

func (a *API) Token(w http.ResponseWriter, r *http.Request) error

Token is the endpoint for OAuth access token requests

func (*API) UpdateInstance

func (a *API) UpdateInstance(w http.ResponseWriter, r *http.Request) error

UpdateInstance updates given instance

func (*API) UserGet

func (a *API) UserGet(w http.ResponseWriter, r *http.Request) error

UserGet returns a user

func (*API) UserUpdate

func (a *API) UserUpdate(w http.ResponseWriter, r *http.Request) error

UserUpdate updates fields on a user

func (*API) Verify

func (a *API) Verify(w http.ResponseWriter, r *http.Request) error

Verify exchanges a confirmation or recovery token to a refresh token

type AccessTokenResponse

type AccessTokenResponse struct {
	Token        string `json:"access_token"`
	TokenType    string `json:"token_type"` // Bearer
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

AccessTokenResponse represents an OAuth2 success response

type DelivcClaims

type DelivcClaims struct {
	jwt.StandardClaims
	Email        string                 `json:"email"`
	AppMetaData  map[string]interface{} `json:"app_metadata"`
	UserMetaData map[string]interface{} `json:"user_metadata"`
}

DelivcClaims is a struct thats used for JWT claims

type DelivcMicroserviceClaims

type DelivcMicroserviceClaims struct {
	jwt.StandardClaims
	SiteURL       string            `json:"site_url"`
	InstanceID    string            `json:"id"`
	DelivcID      string            `json:"delivc_id"`
	FunctionHooks map[string]string `json:"function_hooks"`
}

DelivcMicroserviceClaims claims for the JWT Token

type ErrorCause

type ErrorCause interface {
	Cause() error
}

ErrorCause holds the cause of the error

type ExternalProviderClaims

type ExternalProviderClaims struct {
	DelivcMicroserviceClaims
	Provider    string `json:"provider"`
	InviteToken string `json:"invite_token,omitempty"`
	Referrer    string `json:"referrer,omitempty"`
}

ExternalProviderClaims keeps the claims of the external provider

type ExternalSignupParams

type ExternalSignupParams struct {
	Provider string `json:"provider"`
	Code     string `json:"code"`
}

ExternalSignupParams are the parameters the Signup endpoint accepts

type HTTPError

type HTTPError struct {
	Code            int    `json:"code"`
	Message         string `json:"msg"`
	InternalError   error  `json:"-"`
	InternalMessage string `json:"-"`
	ErrorID         string `json:"error_id,omitempty"`
}

HTTPError is an error with a message and an HTTP status code.

func (*HTTPError) Cause

func (e *HTTPError) Cause() error

Cause returns the root cause error

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) WithInternalError

func (e *HTTPError) WithInternalError(err error) *HTTPError

WithInternalError adds internal error information to the error

func (*HTTPError) WithInternalMessage

func (e *HTTPError) WithInternalMessage(fmtString string, args ...interface{}) *HTTPError

WithInternalMessage adds internal message information to the error

type HookEvent

type HookEvent string

HookEvent holds events

type InstanceRequestParams

type InstanceRequestParams struct {
	UUID       uuid.UUID           `json:"uuid"`
	BaseConfig *conf.Configuration `json:"config"`
}

InstanceRequestParams an instance web request

type InstanceResponse

type InstanceResponse struct {
	models.Instance
	Endpoint string `json:"endpoint"`
	State    string `json:"state"`
}

InstanceResponse an instance web response

type InviteParams

type InviteParams struct {
	Email string                 `json:"email"`
	Data  map[string]interface{} `json:"data"`
}

InviteParams are the parameters the Signup endpoint accepts

type OAuthError

type OAuthError struct {
	Err             string `json:"error"`
	Description     string `json:"error_description,omitempty"`
	InternalError   error  `json:"-"`
	InternalMessage string `json:"-"`
}

OAuthError is the JSON handler for OAuth2 error responses

func (*OAuthError) Cause

func (e *OAuthError) Cause() error

Cause returns the root cause error

func (*OAuthError) Error

func (e *OAuthError) Error() string

func (*OAuthError) WithInternalError

func (e *OAuthError) WithInternalError(err error) *OAuthError

WithInternalError adds internal error information to the error

func (*OAuthError) WithInternalMessage

func (e *OAuthError) WithInternalMessage(fmtString string, args ...interface{}) *OAuthError

WithInternalMessage adds internal message information to the error

type ProviderLabels

type ProviderLabels struct {
	SAML string `json:"saml,omitempty"`
}

ProviderLabels the labels of the SAML providers

type ProviderSettings

type ProviderSettings struct {
	Bitbucket bool `json:"bitbucket"`
	GitHub    bool `json:"github"`
	GitLab    bool `json:"gitlab"`
	Google    bool `json:"google"`
	Facebook  bool `json:"facebook"`
	Email     bool `json:"email"`
	SAML      bool `json:"saml"`
}

ProviderSettings an JSON struct to determine of a provider is enabled

type RecoverParams

type RecoverParams struct {
	Email string `json:"email"`
}

RecoverParams holds the parameters for a password recovery request

type Settings

type Settings struct {
	ExternalProviders ProviderSettings `json:"external"`
	ExternalLabels    ProviderLabels   `json:"external_labels"`
	DisableSignup     bool             `json:"disable_signup"`
	Autoconfirm       bool             `json:"autoconfirm"`
}

Settings holds the settings for the external proiders

type SignupParams

type SignupParams struct {
	Email    string                 `json:"email"`
	Password string                 `json:"password"`
	Data     map[string]interface{} `json:"data"`
	Provider string                 `json:"-"`
	Aud      string                 `json:"-"`
}

SignupParams are the parameters the Signup endpoint accepts

type UserUpdateParams

type UserUpdateParams struct {
	Email            string                 `json:"email"`
	Password         string                 `json:"password"`
	EmailChangeToken string                 `json:"email_change_token"`
	Data             map[string]interface{} `json:"data"`
	AppData          map[string]interface{} `json:"app_metadata,omitempty"`
}

UserUpdateParams parameters for updating a user

type VerifyParams

type VerifyParams struct {
	Type     string `json:"type"`
	Token    string `json:"token"`
	Password string `json:"password"`
}

VerifyParams are the parameters the Verify endpoint accepts

type Webhook

type Webhook struct {
	*conf.WebhookConfig
	// contains filtered or unexported fields
}

Webhook holds webhook informations

type WebhookResponse

type WebhookResponse struct {
	AppMetaData  map[string]interface{} `json:"app_metadata,omitempty"`
	UserMetaData map[string]interface{} `json:"user_metadata,omitempty"`
}

WebhookResponse is a webhook response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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