loginapi

package
v1.41.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const Description = `The Login microservice demonstrates usage of authentication and authorization.`

Description is the human-readable summary of the microservice, surfaced in OpenAPI and discovery.

View Source
const Hostname = "login.example"

Hostname is the default hostname of the microservice.

View Source
const Name = "Login"

Name is the decorative PascalCase name of the microservice.

View Source
const Version = 93

Version is a generation counter bumped on each regeneration, not a semantic version.

Variables

View Source
var AdminOnly = define.Web{
	Host: Hostname, Method: "GET", Route: "/admin-only",
	RequiredClaims: "roles.a",
}

AdminOnly is only accessible by admins.

View Source
var Login = define.Web{
	Host: Hostname, Method: "ANY", Route: "/login",
}

Login renders a simple login screen that authenticates a user. Known users are hardcoded as "admin", "manager" and "user". The password is "password".

View Source
var Logout = define.Web{
	Host: Hostname, Method: "ANY", Route: "/logout",
}

Logout renders a page that logs out the user.

View Source
var ManagerOnly = define.Web{
	Host: Hostname, Method: "GET", Route: "/manager-only",
	RequiredClaims: "roles.m",
}

ManagerOnly is only accessible by managers.

View Source
var Welcome = define.Web{
	Host: Hostname, Method: "ANY", Route: "/welcome",
	RequiredClaims: "roles.a || roles.m || roles.u",
}

Welcome renders a page that is shown to the user after a successful login. Rendering is adjusted based on the user's roles.

Functions

This section is empty.

Types

type Client

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

Client is a lightweight proxy for making unicast calls to the microservice.

func NewClient

func NewClient(caller service.Publisher) Client

NewClient creates a new unicast client proxy to the microservice.

func (Client) AdminOnly

func (_c Client) AdminOnly(ctx context.Context, relativeURL string) (res *http.Response, err error)

AdminOnly is only accessible by admins.

func (Client) ForHost

func (_c Client) ForHost(host string) Client

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (Client) Login

func (_c Client) Login(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)

Login renders a simple login screen that authenticates a user. Known users are hardcoded as "admin", "manager" and "user". The password is "password".

func (Client) Logout

func (_c Client) Logout(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)

Logout renders a page that logs out the user.

func (Client) ManagerOnly

func (_c Client) ManagerOnly(ctx context.Context, relativeURL string) (res *http.Response, err error)

ManagerOnly is only accessible by managers.

func (Client) Welcome

func (_c Client) Welcome(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)

Welcome renders a page that is shown to the user after a successful login. Rendering is adjusted based on the user's roles.

func (Client) WithOptions

func (_c Client) WithOptions(opts ...pub.Option) Client

WithOptions returns a copy of the client with options to be applied to requests.

type MulticastClient

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

MulticastClient is a lightweight proxy for making multicast calls to the microservice.

func NewMulticastClient

func NewMulticastClient(caller service.Publisher) MulticastClient

NewMulticastClient creates a new multicast client proxy to the microservice.

func (MulticastClient) AdminOnly

func (_c MulticastClient) AdminOnly(ctx context.Context, relativeURL string) iter.Seq[*pub.Response]

AdminOnly is only accessible by admins.

func (MulticastClient) ForHost

func (_c MulticastClient) ForHost(host string) MulticastClient

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (MulticastClient) Login

func (_c MulticastClient) Login(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]

Login renders a simple login screen that authenticates a user. Known users are hardcoded as "admin", "manager" and "user". The password is "password".

func (MulticastClient) Logout

func (_c MulticastClient) Logout(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]

Logout renders a page that logs out the user.

func (MulticastClient) ManagerOnly

func (_c MulticastClient) ManagerOnly(ctx context.Context, relativeURL string) iter.Seq[*pub.Response]

ManagerOnly is only accessible by managers.

func (MulticastClient) Welcome

func (_c MulticastClient) Welcome(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]

Welcome renders a page that is shown to the user after a successful login. Rendering is adjusted based on the user's roles.

func (MulticastClient) WithOptions

func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient

WithOptions returns a copy of the client with options to be applied to requests.

Jump to

Keyboard shortcuts

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