users

package
v0.0.0-...-fc6304d Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const APIName = "fishykeys"

APIName is the name of the API as defined in the design.

View Source
const APIVersion = "1.0"

APIVersion is the version of the API as defined in the design.

View Source
const ServiceName = "users"

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 = [5]string{"create user", "list users", "delete user", "auth user", "get operator 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 MakeForbidden

func MakeForbidden(err error) *goa.ServiceError

MakeForbidden builds a goa.ServiceError from an error.

func MakeInternalError

func MakeInternalError(err error) *goa.ServiceError

MakeInternalError builds a goa.ServiceError from an error.

func MakeInvalidParameters

func MakeInvalidParameters(err error) *goa.ServiceError

MakeInvalidParameters builds a goa.ServiceError from an error.

func MakeUnauthorized

func MakeUnauthorized(err error) *goa.ServiceError

MakeUnauthorized builds a goa.ServiceError from an error.

func MakeUserNotFound

func MakeUserNotFound(err error) *goa.ServiceError

MakeUserNotFound builds a goa.ServiceError from an error.

func MakeUsernameTaken

func MakeUsernameTaken(err error) *goa.ServiceError

MakeUsernameTaken builds a goa.ServiceError from an error.

func NewAuthUserEndpoint

func NewAuthUserEndpoint(s Service) goa.Endpoint

NewAuthUserEndpoint returns an endpoint function that calls the method "auth user" of service "users".

func NewCreateUserEndpoint

func NewCreateUserEndpoint(s Service) goa.Endpoint

NewCreateUserEndpoint returns an endpoint function that calls the method "create user" of service "users".

func NewDeleteUserEndpoint

func NewDeleteUserEndpoint(s Service) goa.Endpoint

NewDeleteUserEndpoint returns an endpoint function that calls the method "delete user" of service "users".

func NewGetOperatorTokenEndpoint

func NewGetOperatorTokenEndpoint(s Service) goa.Endpoint

NewGetOperatorTokenEndpoint returns an endpoint function that calls the method "get operator token" of service "users".

func NewListUsersEndpoint

func NewListUsersEndpoint(s Service) goa.Endpoint

NewListUsersEndpoint returns an endpoint function that calls the method "list users" of service "users".

func WrapDeleteUserEndpoint

func WrapDeleteUserEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint

WrapDeleteUserEndpoint wraps the delete user endpoint with the server-side interceptors defined in the design.

func WrapGetOperatorTokenEndpoint

func WrapGetOperatorTokenEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint

WrapGetOperatorTokenEndpoint wraps the get operator token endpoint with the server-side interceptors defined in the design.

func WrapListUsersEndpoint

func WrapListUsersEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint

WrapListUsersEndpoint wraps the list users endpoint with the server-side interceptors defined in the design.

Types

type AuthUserPayload

type AuthUserPayload struct {
	// Username
	Username string
	// Password
	Password string
}

AuthUserPayload is the payload type of the users service auth user method.

type AuthUserResult

type AuthUserResult struct {
	// The username of the authenticated user
	Username *string
	// JWT or session token
	Token *string
}

AuthUserResult is the result type of the users service auth user method.

type AuthentifiedInfo

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

AuthentifiedInfo provides metadata about the current interception. It includes service name, method name, and access to the endpoint.

func (*AuthentifiedInfo) CallType

func (info *AuthentifiedInfo) CallType() goa.InterceptorCallType

CallType returns the type of call the interceptor is handling.

func (*AuthentifiedInfo) Method

func (info *AuthentifiedInfo) Method() string

Method returns the name of the method handling the request.

func (*AuthentifiedInfo) RawPayload

func (info *AuthentifiedInfo) RawPayload() any

RawPayload returns the raw payload of the request.

func (*AuthentifiedInfo) Service

func (info *AuthentifiedInfo) Service() string

Service returns the name of the service handling the request.

type Client

type Client struct {
	CreateUserEndpoint       goa.Endpoint
	ListUsersEndpoint        goa.Endpoint
	DeleteUserEndpoint       goa.Endpoint
	AuthUserEndpoint         goa.Endpoint
	GetOperatorTokenEndpoint goa.Endpoint
}

Client is the "users" service client.

func NewClient

func NewClient(createUser, listUsers, deleteUser, authUser, getOperatorToken goa.Endpoint) *Client

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

func (*Client) AuthUser

func (c *Client) AuthUser(ctx context.Context, p *AuthUserPayload) (res *AuthUserResult, err error)

AuthUser calls the "auth user" endpoint of the "users" service. AuthUser may return the following errors:

  • "unauthorized" (type *goa.ServiceError): Invalid username or password
  • "invalid_parameters" (type *goa.ServiceError): Invalid input
  • "internal_error" (type *goa.ServiceError): Internal server error
  • error: internal error

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, p *CreateUserPayload) (res *CreateUserResult, err error)

CreateUser calls the "create user" endpoint of the "users" service. CreateUser may return the following errors:

  • "username_taken" (type *goa.ServiceError): Username already exists
  • "invalid_parameters" (type *goa.ServiceError): Invalid input
  • "internal_error" (type *goa.ServiceError): Internal server error
  • error: internal error

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, p *DeleteUserPayload) (err error)

DeleteUser calls the "delete user" endpoint of the "users" service. DeleteUser may return the following errors:

  • "user_not_found" (type *goa.ServiceError): User not found
  • "invalid_parameters" (type *goa.ServiceError): Invalid input
  • "internal_error" (type *goa.ServiceError): Internal server error
  • "forbidden" (type *goa.ServiceError): Forbidden access
  • "unauthorized" (type *goa.ServiceError): Unauthorized access
  • error: internal error

func (*Client) GetOperatorToken

func (c *Client) GetOperatorToken(ctx context.Context) (res *GetOperatorTokenResult, err error)

GetOperatorToken calls the "get operator token" endpoint of the "users" service. GetOperatorToken may return the following errors:

  • "internal_error" (type *goa.ServiceError): Internal server error
  • error: internal error

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context) (res []*User, err error)

ListUsers calls the "list users" endpoint of the "users" service. ListUsers may return the following errors:

  • "internal_error" (type *goa.ServiceError): Internal server error
  • "unauthorized" (type *goa.ServiceError): Unauthorized access
  • error: internal error

type CreateUserPayload

type CreateUserPayload struct {
	// Username of the new user
	Username string
	// Password (hashed or plain depending on implementation)
	Password string
}

CreateUserPayload is the payload type of the users service create user method.

type CreateUserResult

type CreateUserResult struct {
	// The username of the created user
	Username string
	// Unique identifier for the user
	ID int
}

CreateUserResult is the result type of the users service create user method.

type DeleteUserPayload

type DeleteUserPayload struct {
	// Username of the user to delete
	Username string
}

DeleteUserPayload is the payload type of the users service delete user method.

type Endpoints

type Endpoints struct {
	CreateUser       goa.Endpoint
	ListUsers        goa.Endpoint
	DeleteUser       goa.Endpoint
	AuthUser         goa.Endpoint
	GetOperatorToken goa.Endpoint
}

Endpoints wraps the "users" service endpoints.

func NewEndpoints

func NewEndpoints(s Service, si ServerInterceptors) *Endpoints

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

func (*Endpoints) Use

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

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

type GetOperatorTokenResult

type GetOperatorTokenResult struct {
	// The username of the account corresponding to the token
	Username *string
	// JWT or session token
	Token *string
}

GetOperatorTokenResult is the result type of the users service get operator token method.

type IsAdminInfo

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

IsAdminInfo provides metadata about the current interception. It includes service name, method name, and access to the endpoint.

func (*IsAdminInfo) CallType

func (info *IsAdminInfo) CallType() goa.InterceptorCallType

CallType returns the type of call the interceptor is handling.

func (*IsAdminInfo) Method

func (info *IsAdminInfo) Method() string

Method returns the name of the method handling the request.

func (*IsAdminInfo) RawPayload

func (info *IsAdminInfo) RawPayload() any

RawPayload returns the raw payload of the request.

func (*IsAdminInfo) Service

func (info *IsAdminInfo) Service() string

Service returns the name of the service handling the request.

type Role

type Role struct {
	// Unique identifier for the role
	ID int
	// Name of the role
	Name string
	// Color associated with the role
	Color string
	// Is this role an admin role?
	Admin bool
	// Role creation timestamp
	CreatedAt string
	// Role last update timestamp
	UpdatedAt string
}

type ServerInterceptors

type ServerInterceptors interface {
	// Server-side interceptor that validates JWT token for HTTP services
	Authentified(ctx context.Context, info *AuthentifiedInfo, next goa.Endpoint) (any, error)
	// Server-side interceptor that checks if the user has admin privileges
	IsAdmin(ctx context.Context, info *IsAdminInfo, next goa.Endpoint) (any, error)
}

ServerInterceptors defines the interface for all server-side interceptors. Server interceptors execute after the request is decoded and before the payload is sent to the service. The implementation is responsible for calling next to complete the request.

type Service

type Service interface {
	// Create a new user
	CreateUser(context.Context, *CreateUserPayload) (res *CreateUserResult, err error)
	// List all users
	ListUsers(context.Context) (res []*User, err error)
	// Delete a user by username
	DeleteUser(context.Context, *DeleteUserPayload) (err error)
	// Authenticate a user with username and password
	AuthUser(context.Context, *AuthUserPayload) (res *AuthUserResult, err error)
	// Retrieve a JWT token that doesn't expire for operator use, corresponding to
	// your user
	GetOperatorToken(context.Context) (res *GetOperatorTokenResult, err error)
}

User service manages user accounts and authentication

type User

type User struct {
	// Unique identifier for the user
	ID int
	// The username
	Username string
	// User creation timestamp
	CreatedAt string
	// User last update timestamp
	UpdatedAt string
	// Roles assigned to the user
	Roles []*Role
}

Jump to

Keyboard shortcuts

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