Documentation
¶
Overview ¶
Package clients serves the OAuth client management API (gRPC and internal HTTP). The underlying queries are sqlc-generated in the sqlcgen subpackage; this file re-exports the pieces repository.go needs via zero-cost type aliases so callers don't leak the sqlcgen import path. ClientModel is the generated row type, named to avoid colliding with the package's own Client domain type (see client.go), which repository.go converts it to.
Index ¶
- Variables
- type Client
- type ClientModel
- type ClientRepository
- func (r *ClientRepository) CreateClient(ctx context.Context, client *Client) (*Client, error)
- func (r *ClientRepository) DeleteClient(ctx context.Context, id string) error
- func (r *ClientRepository) GetClient(ctx context.Context, id string) (*Client, error)
- func (r *ClientRepository) UpsertClient(ctx context.Context, client *Client) (*Client, error)
- type ClientResponse
- type CreateClientInput
- type CreateClientParams
- type GrpcHandler
- func (h *GrpcHandler) CreateClient(ctx context.Context, req *proto.InternalOAuthClientsServiceCreateClientRequest) (*proto.InternalOAuthClientsServiceCreateClientResponse, error)
- func (h *GrpcHandler) DeleteClient(ctx context.Context, req *proto.InternalOAuthClientsServiceDeleteClientRequest) (*proto.InternalOAuthClientsServiceDeleteClientResponse, error)
- func (h *GrpcHandler) GetClient(ctx context.Context, req *proto.InternalOAuthClientsServiceGetClientRequest) (*proto.InternalOAuthClientsServiceGetClientResponse, error)
- func (h *GrpcHandler) UpsertClient(ctx context.Context, req *proto.InternalOAuthClientsServiceUpsertClientRequest) (*proto.InternalOAuthClientsServiceUpsertClientResponse, error)
- type Queries
- type Registry
- func (cm *Registry) CreateClient(ctx context.Context, client *Client) (*Client, error)
- func (cm *Registry) DeleteClient(ctx context.Context, clientID string) error
- func (cm *Registry) GetClient(ctx context.Context, clientID string) (*Client, error)
- func (cm *Registry) SetupRoutes(mux *http.ServeMux)
- func (cm *Registry) UpsertClient(ctx context.Context, client *Client) (*Client, error)
- type UpsertClientParams
Constants ¶
This section is empty.
Variables ¶
var ( ErrClientNotFound = errors.New("client not found") ErrClientExists = errors.New("client already exists") )
var ErrInvalidClient = errors.New("invalid client")
var New = sqlcgen.New
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
fosite.DefaultClient
Name string `json:"client_name"`
Owner string `json:"owner"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Trusted bool `json:"trusted"`
}
Client extends fosite.DefaultClient with IAM-specific fields.
func (*Client) GetCreatedAt ¶
func (*Client) GetUpdatedAt ¶
type ClientModel ¶ added in v1.47.0
type ClientRepository ¶
type ClientRepository struct {
// contains filtered or unexported fields
}
func NewClientRepository ¶
func NewClientRepository(db pkgstorage.DBTX) *ClientRepository
func (*ClientRepository) CreateClient ¶
func (*ClientRepository) DeleteClient ¶
func (r *ClientRepository) DeleteClient(ctx context.Context, id string) error
func (*ClientRepository) UpsertClient ¶ added in v1.47.0
type ClientResponse ¶
type ClientResponse struct {
ID string `json:"client_id"`
RedirectURIs []string `json:"redirect_uris"`
GrantTypes []string `json:"grant_types"`
ResponseTypes []string `json:"response_types"`
Scopes []string `json:"scopes"`
Public bool `json:"public"`
Name string `json:"client_name"`
Owner string `json:"owner"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Trusted bool `json:"trusted"`
}
ClientResponse is used for API responses to ensure the secret is never exposed.
func ToResponse ¶
func ToResponse(c *Client) *ClientResponse
type CreateClientInput ¶
type CreateClientInput struct {
ID string `json:"client_id"`
Secret string `json:"client_secret"`
RedirectURIs []string `json:"redirect_uris"`
GrantTypes []string `json:"grant_types"`
ResponseTypes []string `json:"response_types"`
Scopes []string `json:"scopes"`
Public bool `json:"public"`
Name string `json:"client_name"`
Owner string `json:"owner"`
Trusted bool `json:"trusted"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
CreateClientInput is used for API requests to create a client. It uses string for Secret to allow plain text secrets in JSON payloads.
func (*CreateClientInput) ToClient ¶
func (i *CreateClientInput) ToClient() *Client
ToClient converts a CreateClientInput to a Client.
type CreateClientParams ¶ added in v1.47.0
type CreateClientParams = sqlcgen.CreateClientParams
type GrpcHandler ¶ added in v1.31.1
type GrpcHandler struct {
proto.UnimplementedInternalOAuthClientsServiceServer
// contains filtered or unexported fields
}
GrpcHandler serves the InternalOAuthClientsService gRPC API. It mirrors the internal HTTP client-management endpoints, delegating to the same registry so both transports share identical create/get/delete behaviour.
func NewGrpcHandler ¶ added in v1.31.1
func NewGrpcHandler(registry clientRegistry) *GrpcHandler
func (*GrpcHandler) CreateClient ¶ added in v1.31.1
func (h *GrpcHandler) CreateClient(ctx context.Context, req *proto.InternalOAuthClientsServiceCreateClientRequest) (*proto.InternalOAuthClientsServiceCreateClientResponse, error)
func (*GrpcHandler) DeleteClient ¶ added in v1.31.1
func (h *GrpcHandler) DeleteClient(ctx context.Context, req *proto.InternalOAuthClientsServiceDeleteClientRequest) (*proto.InternalOAuthClientsServiceDeleteClientResponse, error)
func (*GrpcHandler) GetClient ¶ added in v1.31.1
func (h *GrpcHandler) GetClient(ctx context.Context, req *proto.InternalOAuthClientsServiceGetClientRequest) (*proto.InternalOAuthClientsServiceGetClientResponse, error)
func (*GrpcHandler) UpsertClient ¶ added in v1.51.0
func (h *GrpcHandler) UpsertClient(ctx context.Context, req *proto.InternalOAuthClientsServiceUpsertClientRequest) (*proto.InternalOAuthClientsServiceUpsertClientResponse, error)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry(r *ClientRepository, hasher fosite.Hasher) *Registry
func (*Registry) CreateClient ¶
func (*Registry) DeleteClient ¶
func (*Registry) SetupRoutes ¶
type UpsertClientParams ¶ added in v1.47.0
type UpsertClientParams = sqlcgen.UpsertClientParams