authz

package
v1.1.66-test Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 7 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticateRequest

type AuthenticateRequest struct {
	Token   string `json:"token"`
	Profile string `json:"profile"`
	Scope   string `json:"scope,omitempty"` // e.g., org name
}

AuthenticateRequest represents an authentication request

type AuthenticateResponse

type AuthenticateResponse struct {
	User          *User  `json:"user,omitempty"`
	Authenticated bool   `json:"authenticated"`
	Error         string `json:"error,omitempty"`
}

AuthenticateResponse represents an authentication response

type AuthorizeRequest

type AuthorizeRequest struct {
	Token       string   `json:"token"`
	Profile     string   `json:"profile"`
	Permissions []string `json:"permissions,omitempty"`
	Scope       string   `json:"scope,omitempty"` // e.g., org name
}

AuthorizeRequest represents an authorization request

type AuthorizeResponse

type AuthorizeResponse struct {
	User       *User  `json:"user,omitempty"`
	Authorized bool   `json:"authorized"`
	Error      string `json:"error,omitempty"`
}

AuthorizeResponse represents an authorization response

type Client

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

Client is an HTTP client for the authz service

func NewClient

func NewClient(baseURL string, opts ...ClientOption) *Client

NewClient creates a new authz client

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context, req *AuthenticateRequest) (*AuthenticateResponse, error)

Authenticate authenticates a token using the specified profile

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context, req *AuthorizeRequest) (*AuthorizeResponse, error)

Authorize authenticates and authorizes a token using the specified profile

func (*Client) AuthorizeAccountUser

func (c *Client) AuthorizeAccountUser(ctx context.Context, token, accountId string, roles ...string) (*User, error)

AuthorizeAccountUser is a convenience method that authorizes account users

func (*Client) AuthorizeAnyValidUser

func (c *Client) AuthorizeAnyValidUser(ctx context.Context, token string, actions ...string) (*User, error)

AuthorizeAnyValidUser is a convenience method that authorizes any valid user

func (*Client) AuthorizeMetering

func (c *Client) AuthorizeMetering(ctx context.Context, token, scope string, actions ...string) (*User, error)

AuthorizeMetering is a convenience method for metering service authorization

func (*Client) AuthorizeOrgUser

func (c *Client) AuthorizeOrgUser(ctx context.Context, token, org string, permissions []string) (*User, error)

AuthorizeOrgUser is a convenience method that authorizes users for an org with given permissions

func (*Client) AuthorizeRootUser

func (c *Client) AuthorizeRootUser(ctx context.Context, token string) (*User, error)

AuthorizeRootUser is a convenience method that authorizes root users only

type ClientOption

type ClientOption func(*Client)

ClientOption configures the client

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient sets a custom HTTP client

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout sets the HTTP client timeout

type ProfileName

type ProfileName string

ProfileName represents a named authorization profile

const (
	ProfileAnyValidUser ProfileName = "any-valid-user"
	ProfileRootUser     ProfileName = "root-user"
	ProfileAccountUser  ProfileName = "account-user"
	ProfileDataService  ProfileName = "data-service"
	ProfileMetering     ProfileName = "metering"
)

type User

type User struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
	Root  bool   `json:"root,omitempty"`
	Org   string `json:"org,omitempty"`
	Extra any    `json:"extra,omitempty"`
}

User represents authenticated user information

Jump to

Keyboard shortcuts

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