securedservice

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

View Source
const ServiceName = "secured_service"

ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.

Variables

View Source
var MethodNames = [4]string{"signin", "secure", "doubly_secure", "also_doubly_secure"}

MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.

Functions

func NewAlsoDoublySecureEndpoint

func NewAlsoDoublySecureEndpoint(s Service, authJWTFn security.AuthJWTFunc, authAPIKeyFn security.AuthAPIKeyFunc, authOAuth2Fn security.AuthOAuth2Func, authBasicFn security.AuthBasicFunc) goa.Endpoint

NewAlsoDoublySecureEndpoint returns an endpoint function that calls the method "also_doubly_secure" of service "secured_service".

func NewDoublySecureEndpoint

func NewDoublySecureEndpoint(s Service, authJWTFn security.AuthJWTFunc, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint

NewDoublySecureEndpoint returns an endpoint function that calls the method "doubly_secure" of service "secured_service".

func NewSecureEndpoint

func NewSecureEndpoint(s Service, authJWTFn security.AuthJWTFunc) goa.Endpoint

NewSecureEndpoint returns an endpoint function that calls the method "secure" of service "secured_service".

func NewSigninEndpoint

func NewSigninEndpoint(s Service, authBasicFn security.AuthBasicFunc) goa.Endpoint

NewSigninEndpoint returns an endpoint function that calls the method "signin" of service "secured_service".

Types

type AlsoDoublySecurePayload

type AlsoDoublySecurePayload struct {
	// Username used to perform signin
	Username *string
	// Password used to perform signin
	Password *string
	// API key
	Key *string
	// JWT used for authentication
	Token      *string
	OauthToken *string
}

AlsoDoublySecurePayload is the payload type of the secured_service service also_doubly_secure method.

type Auther

type Auther interface {
	// BasicAuth implements the authorization logic for the Basic security scheme.
	BasicAuth(ctx context.Context, user, pass string, schema *security.BasicScheme) (context.Context, error)
	// JWTAuth implements the authorization logic for the JWT security scheme.
	JWTAuth(ctx context.Context, token string, schema *security.JWTScheme) (context.Context, error)
	// APIKeyAuth implements the authorization logic for the APIKey security scheme.
	APIKeyAuth(ctx context.Context, key string, schema *security.APIKeyScheme) (context.Context, error)
	// OAuth2Auth implements the authorization logic for the OAuth2 security scheme.
	OAuth2Auth(ctx context.Context, token string, schema *security.OAuth2Scheme) (context.Context, error)
}

Auther defines the authorization functions to be implemented by the service.

type Client

type Client struct {
	SigninEndpoint           goa.Endpoint
	SecureEndpoint           goa.Endpoint
	DoublySecureEndpoint     goa.Endpoint
	AlsoDoublySecureEndpoint goa.Endpoint
}

Client is the "secured_service" service client.

func NewClient

func NewClient(signin, secure, doublySecure, alsoDoublySecure goa.Endpoint) *Client

NewClient initializes a "secured_service" service client given the endpoints.

func (*Client) AlsoDoublySecure

func (c *Client) AlsoDoublySecure(ctx context.Context, p *AlsoDoublySecurePayload) (res string, err error)

AlsoDoublySecure calls the "also_doubly_secure" endpoint of the "secured_service" service. AlsoDoublySecure may return the following errors:

  • "invalid-scopes" (type InvalidScopes)
  • error: internal error

func (*Client) DoublySecure

func (c *Client) DoublySecure(ctx context.Context, p *DoublySecurePayload) (res string, err error)

DoublySecure calls the "doubly_secure" endpoint of the "secured_service" service. DoublySecure may return the following errors:

  • "invalid-scopes" (type InvalidScopes)
  • error: internal error

func (*Client) Secure

func (c *Client) Secure(ctx context.Context, p *SecurePayload) (res string, err error)

Secure calls the "secure" endpoint of the "secured_service" service. Secure may return the following errors:

  • "invalid-scopes" (type InvalidScopes)
  • error: internal error

func (*Client) Signin

func (c *Client) Signin(ctx context.Context, p *SigninPayload) (res *Creds, err error)

Signin calls the "signin" endpoint of the "secured_service" service.

type Creds

type Creds struct {
	// JWT token
	JWT string
	// API Key
	APIKey string
	// OAuth2 token
	OauthToken string
}

Creds is the result type of the secured_service service signin method.

type DoublySecurePayload

type DoublySecurePayload struct {
	// API key
	Key string
	// JWT used for authentication
	Token string
}

DoublySecurePayload is the payload type of the secured_service service doubly_secure method.

type Endpoints

type Endpoints struct {
	Signin           goa.Endpoint
	Secure           goa.Endpoint
	DoublySecure     goa.Endpoint
	AlsoDoublySecure goa.Endpoint
}

Endpoints wraps the "secured_service" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

NewEndpoints wraps the methods of the "secured_service" service with endpoints.

func (*Endpoints) Use

func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint)

Use applies the given middleware to all the "secured_service" service endpoints.

type InvalidScopes

type InvalidScopes string

Token scopes are invalid

func (InvalidScopes) Error

func (e InvalidScopes) Error() string

Error returns an error description.

func (InvalidScopes) ErrorName

func (e InvalidScopes) ErrorName() string

ErrorName returns "invalid-scopes".

type SecurePayload

type SecurePayload struct {
	// Whether to force auth failure even with a valid JWT
	Fail *bool
	// JWT used for authentication
	Token string
}

SecurePayload is the payload type of the secured_service service secure method.

type Service

type Service interface {
	// Creates a valid JWT
	Signin(context.Context, *SigninPayload) (res *Creds, err error)
	// This action is secured with the jwt scheme
	Secure(context.Context, *SecurePayload) (res string, err error)
	// This action is secured with the jwt scheme and also requires an API key
	// query string.
	DoublySecure(context.Context, *DoublySecurePayload) (res string, err error)
	// This action is secured with the jwt scheme and also requires an API key
	// header.
	AlsoDoublySecure(context.Context, *AlsoDoublySecurePayload) (res string, err error)
}

The secured service exposes endpoints that require valid authorization credentials.

type SigninPayload

type SigninPayload struct {
	// Username used to perform signin
	Username string
	// Password used to perform signin
	Password string
}

Credentials used to authenticate to retrieve JWT token

type Unauthorized

type Unauthorized string

Credentials are invalid

func (Unauthorized) Error

func (e Unauthorized) Error() string

Error returns an error description.

func (Unauthorized) ErrorName

func (e Unauthorized) ErrorName() string

ErrorName returns "unauthorized".

Jump to

Keyboard shortcuts

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