session

package
v0.0.0-...-69a499a Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "session"

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 = [9]string{"refresh", "logout", "logout-other", "logout-specific", "get-sessions", "redeemToken", "clean-sessions", "clean-login-token", "clean-merge-token"}

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 MakeBadRequest

func MakeBadRequest(err error) *goa.ServiceError

MakeBadRequest builds a goa.ServiceError from an error.

func MakeForbidden

func MakeForbidden(err error) *goa.ServiceError

MakeForbidden builds a goa.ServiceError from an error.

func MakeInternalServerError

func MakeInternalServerError(err error) *goa.ServiceError

MakeInternalServerError builds a goa.ServiceError from an error.

func MakeNotFound

func MakeNotFound(err error) *goa.ServiceError

MakeNotFound builds a goa.ServiceError from an error.

func MakeUnauthorized

func MakeUnauthorized(err error) *goa.ServiceError

MakeUnauthorized builds a goa.ServiceError from an error.

func NewCleanLoginTokenEndpoint

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

NewCleanLoginTokenEndpoint returns an endpoint function that calls the method "clean-login-token" of service "session".

func NewCleanMergeTokenEndpoint

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

NewCleanMergeTokenEndpoint returns an endpoint function that calls the method "clean-merge-token" of service "session".

func NewCleanSessionsEndpoint

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

NewCleanSessionsEndpoint returns an endpoint function that calls the method "clean-sessions" of service "session".

func NewGetSessionsEndpoint

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

NewGetSessionsEndpoint returns an endpoint function that calls the method "get-sessions" of service "session".

func NewLogoutEndpoint

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

NewLogoutEndpoint returns an endpoint function that calls the method "logout" of service "session".

func NewLogoutOtherEndpoint

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

NewLogoutOtherEndpoint returns an endpoint function that calls the method "logout-other" of service "session".

func NewLogoutSpecificEndpoint

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

NewLogoutSpecificEndpoint returns an endpoint function that calls the method "logout-specific" of service "session".

func NewRedeemTokenEndpoint

func NewRedeemTokenEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint

NewRedeemTokenEndpoint returns an endpoint function that calls the method "redeemToken" of service "session".

func NewRefreshEndpoint

func NewRefreshEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint

NewRefreshEndpoint returns an endpoint function that calls the method "refresh" of service "session".

func NewViewedAllSessions

func NewViewedAllSessions(res *AllSessions, view string) *sessionviews.AllSessions

NewViewedAllSessions initializes viewed result type AllSessions from result type AllSessions using the given view.

Types

type AllSessions

type AllSessions struct {
	CurrentSession *Session
	OtherSessions  SessionCollection
}

AllSessions is the result type of the session service get-sessions method.

func NewAllSessions

func NewAllSessions(vres *sessionviews.AllSessions) *AllSessions

NewAllSessions initializes result type AllSessions from viewed result type AllSessions.

type Auther

type Auther interface {
	// APIKeyAuth implements the authorization logic for the APIKey security scheme.
	APIKeyAuth(ctx context.Context, key string, schema *security.APIKeyScheme) (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)
}

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

type CleanLoginTokenPayload

type CleanLoginTokenPayload struct {
	Authorization *string
	XSession      *string
	APIKey        *string
}

CleanLoginTokenPayload is the payload type of the session service clean-login-token method.

type CleanMergeTokenPayload

type CleanMergeTokenPayload struct {
	Authorization *string
	XSession      *string
	APIKey        *string
}

CleanMergeTokenPayload is the payload type of the session service clean-merge-token method.

type CleanSessionsPayload

type CleanSessionsPayload struct {
	Authorization *string
	XSession      *string
	APIKey        *string
}

CleanSessionsPayload is the payload type of the session service clean-sessions method.

type Client

type Client struct {
	RefreshEndpoint         goa.Endpoint
	LogoutEndpoint          goa.Endpoint
	LogoutOtherEndpoint     goa.Endpoint
	LogoutSpecificEndpoint  goa.Endpoint
	GetSessionsEndpoint     goa.Endpoint
	RedeemTokenEndpoint     goa.Endpoint
	CleanSessionsEndpoint   goa.Endpoint
	CleanLoginTokenEndpoint goa.Endpoint
	CleanMergeTokenEndpoint goa.Endpoint
}

Client is the "session" service client.

func NewClient

func NewClient(refresh, logout, logoutOther, logoutSpecific, getSessions, redeemToken, cleanSessions, cleanLoginToken, cleanMergeToken goa.Endpoint) *Client

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

func (*Client) CleanLoginToken

func (c *Client) CleanLoginToken(ctx context.Context, p *CleanLoginTokenPayload) (err error)

CleanLoginToken calls the "clean-login-token" endpoint of the "session" service. CleanLoginToken may return the following errors:

  • "Forbidden" (type *goa.ServiceError)
  • error: internal error

func (*Client) CleanMergeToken

func (c *Client) CleanMergeToken(ctx context.Context, p *CleanMergeTokenPayload) (err error)

CleanMergeToken calls the "clean-merge-token" endpoint of the "session" service. CleanMergeToken may return the following errors:

  • "Forbidden" (type *goa.ServiceError)
  • error: internal error

func (*Client) CleanSessions

func (c *Client) CleanSessions(ctx context.Context, p *CleanSessionsPayload) (err error)

CleanSessions calls the "clean-sessions" endpoint of the "session" service. CleanSessions may return the following errors:

  • "Forbidden" (type *goa.ServiceError)
  • error: internal error

func (*Client) GetSessions

func (c *Client) GetSessions(ctx context.Context, p *GetSessionsPayload) (res *AllSessions, err error)

GetSessions calls the "get-sessions" endpoint of the "session" service. GetSessions may return the following errors:

  • "InternalServerError" (type *goa.ServiceError)
  • error: internal error

func (*Client) Logout

func (c *Client) Logout(ctx context.Context, p *LogoutPayload) (err error)

Logout calls the "logout" endpoint of the "session" service. Logout may return the following errors:

  • "BadRequest" (type *goa.ServiceError)
  • "InternalServerError" (type *goa.ServiceError)
  • error: internal error

func (*Client) LogoutOther

func (c *Client) LogoutOther(ctx context.Context, p *LogoutOtherPayload) (err error)

LogoutOther calls the "logout-other" endpoint of the "session" service. LogoutOther may return the following errors:

  • "BadRequest" (type *goa.ServiceError)
  • "InternalServerError" (type *goa.ServiceError)
  • error: internal error

func (*Client) LogoutSpecific

func (c *Client) LogoutSpecific(ctx context.Context, p *LogoutSpecificPayload) (err error)

LogoutSpecific calls the "logout-specific" endpoint of the "session" service. LogoutSpecific may return the following errors:

  • "BadRequest" (type *goa.ServiceError)
  • "NotFound" (type *goa.ServiceError)
  • "InternalServerError" (type *goa.ServiceError)
  • error: internal error

func (*Client) RedeemToken

func (c *Client) RedeemToken(ctx context.Context, p *RedeemTokenPayload) (res *RedeemTokenResult, err error)

RedeemToken calls the "redeemToken" endpoint of the "session" service. RedeemToken may return the following errors:

  • "Forbidden" (type *goa.ServiceError)
  • "InternalServerError" (type *goa.ServiceError)
  • error: internal error

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, p *RefreshPayload) (res *RefreshResult, err error)

Refresh calls the "refresh" endpoint of the "session" service. Refresh may return the following errors:

  • "Unauthorized" (type *goa.ServiceError)
  • "BadRequest" (type *goa.ServiceError)
  • "InternalServerError" (type *goa.ServiceError)
  • error: internal error

type Endpoints

type Endpoints struct {
	Refresh         goa.Endpoint
	Logout          goa.Endpoint
	LogoutOther     goa.Endpoint
	LogoutSpecific  goa.Endpoint
	GetSessions     goa.Endpoint
	RedeemToken     goa.Endpoint
	CleanSessions   goa.Endpoint
	CleanLoginToken goa.Endpoint
	CleanMergeToken goa.Endpoint
}

Endpoints wraps the "session" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

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

func (*Endpoints) Use

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

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

type GetSessionsPayload

type GetSessionsPayload struct {
	Authorization *string
	XSession      *string
	APIKey        *string
}

GetSessionsPayload is the payload type of the session service get-sessions method.

type LogoutOtherPayload

type LogoutOtherPayload struct {
	Authorization *string
	XSession      *string
	APIKey        *string
}

LogoutOtherPayload is the payload type of the session service logout-other method.

type LogoutPayload

type LogoutPayload struct {
	Authorization *string
	XSession      *string
	APIKey        *string
}

LogoutPayload is the payload type of the session service logout method.

type LogoutSpecificPayload

type LogoutSpecificPayload struct {
	SessionID     *string
	Authorization *string
	XSession      *string
	APIKey        *string
}

LogoutSpecificPayload is the payload type of the session service logout-specific method.

type RedeemTokenPayload

type RedeemTokenPayload struct {
	// A merge token for merging into an account
	Token     string
	UserAgent *string
	APIKey    *string
}

RedeemTokenPayload is the payload type of the session service redeemToken method.

type RedeemTokenResult

type RedeemTokenResult struct {
	Authorization *string
	XSession      *string
}

RedeemTokenResult is the result type of the session service redeemToken method.

type RefreshPayload

type RefreshPayload struct {
	XSession *string
	APIKey   *string
}

RefreshPayload is the payload type of the session service refresh method.

type RefreshResult

type RefreshResult struct {
	Authorization *string
	XSession      *string
}

RefreshResult is the result type of the session service refresh method.

type Service

type Service interface {
	// Take a user's session token and refresh it, also returns a new
	// authentication token
	Refresh(context.Context, *RefreshPayload) (res *RefreshResult, err error)
	// Takes a user's auth token, and logs-out the session associated with it
	Logout(context.Context, *LogoutPayload) (err error)
	// Logout all sessions for the current user except their current session
	LogoutOther(context.Context, *LogoutOtherPayload) (err error)
	// Logout of a specific session
	LogoutSpecific(context.Context, *LogoutSpecificPayload) (err error)
	// Gets all of the sessions that are associated with the currently logged in
	// user
	GetSessions(context.Context, *GetSessionsPayload) (res *AllSessions, err error)
	// Redeems a login token for credentials
	RedeemToken(context.Context, *RedeemTokenPayload) (res *RedeemTokenResult, err error)
	// Deletes all the sessions that have expired
	CleanSessions(context.Context, *CleanSessionsPayload) (err error)
	// Cleans old login tokens from the database
	CleanLoginToken(context.Context, *CleanLoginTokenPayload) (err error)
	// Cleans old account merge tokens from the database
	CleanMergeToken(context.Context, *CleanMergeTokenPayload) (err error)
}

Service is the session service interface.

type Session

type Session struct {
	// Unique unchanging session ID
	ID string
	// ID of the user this session is for
	UserID string
	// Time that this session was last used
	LastUsed string
	// The browser and browser version connected with this session
	Browser string
	// The OS of the system where this session was used
	Os string
	// The last IP address where this session was used
	IP string
	// A humanReadable string describing the last known location of the session
	Location string
	// The latitude of the last known location of the session
	Latitude string
	// The longitude of the last known location of the session
	Longitude string
	// Whether the session was from a mobile device
	IsMobile bool
	// The URL of the Google map to show the location, suitable for using in an img
	// tag
	MapURL string
}

A session for a user, associated with a specific browser

type SessionCollection

type SessionCollection []*Session

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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