identity

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package identity carries the verified viewer of a request in its context, with the viewer's token and, while serving a call from another app, that app.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Caller

func Caller(ctx context.Context) string

Caller returns the app whose call ctx serves, or "".

func Token

func Token(ctx context.Context) string

Token returns the viewer token ctx carries, or "".

func With

func With(ctx context.Context, id Identity) context.Context

With returns a copy of ctx carrying a copy of id.

func WithCaller

func WithCaller(ctx context.Context, app string) context.Context

WithCaller returns a copy of ctx carrying the app whose call is being served.

func WithToken

func WithToken(ctx context.Context, token string) context.Context

WithToken returns a copy of ctx carrying the viewer token of the request being served.

Types

type Identity

type Identity struct {
	Subject string
	Name    string
	Groups  []string
	Roles   []string
}

Identity is a viewer verified by the company login. The zero Identity has no roles or groups.

func From

func From(ctx context.Context) Identity

From returns a copy of the identity carried by ctx, or the zero Identity. Changing the copy does not change what ctx carries.

func (Identity) Authenticated

func (i Identity) Authenticated() bool

Authenticated reports whether this is a verified viewer rather than the zero Identity.

func (Identity) HasRole

func (i Identity) HasRole(role string) bool

HasRole reports whether the viewer has role.

func (Identity) InGroup

func (i Identity) InGroup(group string) bool

InGroup reports whether the viewer is in group.

Jump to

Keyboard shortcuts

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