identity

package
v0.12.0 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 is the viewer's stable id, at most 512 bytes; empty only for the zero Identity.
	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