authz

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 7 Imported by: 0

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