client

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewShorelineClientFromEnv

func NewShorelineClientFromEnv(httpClient *http.Client) *Client

NewShorelineClientFromEnv read the config from the environment variables

func (*Client) Close

func (client *Client) Close()

func (*Client) GetUnverifiedUsers

func (client *Client) GetUnverifiedUsers(ctx context.Context, token string) ([]UserData, error)

Get users with unverified email

func (*Client) GetUser

func (client *Client) GetUser(ctx context.Context, userId, token string) (*UserData, error)

Get user details for the given user (from legacy auth system) In this case the userID could be the actual ID or an email address

func (*Client) Start

func (client *Client) Start() error

Start starts the client and makes it ready for us. This must be done before using any of the functionality that requires a server token

func (*Client) TokenProvide

func (client *Client) TokenProvide() string

Return a valid service token

func (*Client) UpdateUser

func (client *Client) UpdateUser(ctx context.Context, userId string, userUpdate UserUpdate, token string) error

Update a user in backloops legacy authentication db (shoreline)

type ClientBuilder

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

func NewShorelineClientBuilder

func NewShorelineClientBuilder() *ClientBuilder

func (*ClientBuilder) Build

func (b *ClientBuilder) Build() *Client

Build return client from builder

func (*ClientBuilder) WithConfig

func (b *ClientBuilder) WithConfig(val *ClientConfig) *ClientBuilder

WithConfig sets the whole config

func (*ClientBuilder) WithHTTPClient

func (b *ClientBuilder) WithHTTPClient(httpClient *http.Client) *ClientBuilder

WithHTTPClient set the HTTP client

func (*ClientBuilder) WithHost

func (b *ClientBuilder) WithHost(host string) *ClientBuilder

WithHost set the host

func (*ClientBuilder) WithName

func (b *ClientBuilder) WithName(val string) *ClientBuilder

WithName sets the name of the server (config)

func (*ClientBuilder) WithSecret

func (b *ClientBuilder) WithSecret(val string) *ClientBuilder

WithSecret sets the secret (config)

func (*ClientBuilder) WithTokenGetInterval

func (b *ClientBuilder) WithTokenGetInterval(val time.Duration) *ClientBuilder

WithTokenGetInterval sets the duration interval for token initial ack (config)

func (*ClientBuilder) WithTokenRefreshInterval

func (b *ClientBuilder) WithTokenRefreshInterval(val time.Duration) *ClientBuilder

WithTokenRefreshInterval sets the duration interval for token refresh (config)

type ClientConfig

type ClientConfig struct {
	Name                 string        `json:"name"`                 // The name of this server for use in obtaining a server token
	Secret               string        `json:"secret"`               // The secret used along with the name to obtain a server token
	TokenRefreshInterval time.Duration `json:"tokenRefreshInterval"` // The amount of time between refreshes of the server token
	TokenGetInterval     time.Duration `json:"tokenGetInterval"`     // The amount of time between attempts to get the server token
}

type ShorelineMockClient

type ShorelineMockClient struct {
	mock.Mock
	ServerToken  string
	Unauthorized bool
	UserID       string
	IsServer     bool
}

func NewMock

func NewMock(token string) *ShorelineMockClient

func (*ShorelineMockClient) Close

func (client *ShorelineMockClient) Close()

func (*ShorelineMockClient) DeleteUser

func (client *ShorelineMockClient) DeleteUser(userId string, token string) error

func (*ShorelineMockClient) GetUnverifiedUsers

func (client *ShorelineMockClient) GetUnverifiedUsers(token string) ([]UserData, error)

func (*ShorelineMockClient) GetUser

func (client *ShorelineMockClient) GetUser(userID, token string) (*UserData, error)

func (*ShorelineMockClient) Start

func (client *ShorelineMockClient) Start() error

func (*ShorelineMockClient) TokenProvide

func (client *ShorelineMockClient) TokenProvide() string

func (*ShorelineMockClient) UpdateUser

func (client *ShorelineMockClient) UpdateUser(userID string, userUpdate UserUpdate, token string) error

type UserData

type UserData struct {
	UserID         string   `json:"userid,omitempty" bson:"userid,omitempty"` // map userid to id
	Username       string   `json:"username,omitempty" bson:"username,omitempty"`
	Emails         []string `json:"emails,omitempty" bson:"emails,omitempty"`
	PasswordExists bool     `json:"passwordExists,omitempty"` // Does a password exist for the user?
	Roles          []string `json:"roles,omitempty" bson:"roles,omitempty"`
	TermsAccepted  string   `json:"termsAccepted,omitempty" bson:"termsAccepted,omitempty"`
	EmailVerified  bool     `json:"emailVerified" bson:"authenticated"` //tag is name `authenticated` for historical reasons
	IdVerified     bool     `json:"idVerified"`
}

UserData is the data structure returned from a successful Login query.

type UserUpdate

type UserUpdate struct {
	Username      *string   `json:"username,omitempty"`
	Emails        *[]string `json:"emails,omitempty"`
	Password      *string   `json:"password,omitempty"`
	Roles         *[]string `json:"roles,omitempty"`
	EmailVerified *bool     `json:"emailVerified,omitempty"`
}

UserUpdate is the data structure for updating of a users details

Jump to

Keyboard shortcuts

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