Documentation
¶
Index ¶
- type AuthenticateRequest
- type AuthenticateResponse
- type AuthorizeRequest
- type AuthorizeResponse
- type Client
- func (c *Client) Authenticate(ctx context.Context, req *AuthenticateRequest) (*AuthenticateResponse, error)
- func (c *Client) Authorize(ctx context.Context, req *AuthorizeRequest) (*AuthorizeResponse, error)
- func (c *Client) AuthorizeAccountUser(ctx context.Context, token, accountId string, roles ...string) (*User, error)
- func (c *Client) AuthorizeAnyValidUser(ctx context.Context, token string, actions ...string) (*User, error)
- func (c *Client) AuthorizeMetering(ctx context.Context, token, scope string, actions ...string) (*User, error)
- func (c *Client) AuthorizeOrgUser(ctx context.Context, token, org string, permissions []string) (*User, error)
- func (c *Client) AuthorizeRootUser(ctx context.Context, token string) (*User, error)
- type ClientOption
- type ProfileName
- type User
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
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" )