identity

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package identity provides shared types for edge-injected user identity. In SaaS mode, the Cloudflare Edge Router (formerly Kong Gateway) validates the incoming JWT and injects X-User-ID, X-Org-ID, X-User-Email, and X-User-Roles headers. This package makes those values available throughout the request lifecycle via context.

Use edgeauth.Middleware (CF Edge Router) or kong.Middleware (Kong) to populate the identity into context before calling FromContext().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, id *Identity) context.Context

NewContext returns a new context with the Identity stored.

Types

type Identity

type Identity struct {
	UserID string   `json:"user_id,omitempty"`
	OrgID  string   `json:"org_id,omitempty"`
	Email  string   `json:"email,omitempty"`
	Tier   string   `json:"tier,omitempty"`
	Roles  []string `json:"roles,omitempty"`
}

Identity holds the user identity injected by the Cloudflare Edge Router (formerly Kong Gateway) after Auth0 JWT validation.

func FromContext

func FromContext(ctx context.Context) *Identity

FromContext retrieves the Identity from context. Returns nil if not present.

func FromHeaders

func FromHeaders(get func(string) string) *Identity

FromHeaders extracts an Identity from HTTP headers.

func (*Identity) HasRole

func (id *Identity) HasRole(role string) bool

HasRole checks if the identity has a specific role (case-insensitive).

func (*Identity) IsAuthenticated

func (id *Identity) IsAuthenticated() bool

IsAuthenticated returns true if at least a UserID is present.

Jump to

Keyboard shortcuts

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