clients

package
v1.52.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 19 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	ErrClientNotFound = errors.New("client not found")
	ErrClientExists   = errors.New("client already exists")
)
View Source
var ErrInvalidClient = errors.New("invalid client")
View Source
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 (c *Client) GetCreatedAt() time.Time

func (*Client) GetName

func (c *Client) GetName() string

func (*Client) GetOwner

func (c *Client) GetOwner() string

func (*Client) GetUpdatedAt

func (c *Client) GetUpdatedAt() time.Time

func (*Client) IsTrusted

func (c *Client) IsTrusted() bool

type ClientModel added in v1.47.0

type ClientModel = sqlcgen.Client

type ClientRepository

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

func NewClientRepository

func NewClientRepository(db pkgstorage.DBTX) *ClientRepository

func (*ClientRepository) CreateClient

func (r *ClientRepository) CreateClient(ctx context.Context, client *Client) (*Client, error)

func (*ClientRepository) DeleteClient

func (r *ClientRepository) DeleteClient(ctx context.Context, id string) error

func (*ClientRepository) GetClient

func (r *ClientRepository) GetClient(ctx context.Context, id string) (*Client, error)

func (*ClientRepository) UpsertClient added in v1.47.0

func (r *ClientRepository) UpsertClient(ctx context.Context, client *Client) (*Client, error)

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

type Queries added in v1.47.0

type Queries = sqlcgen.Queries

type Registry

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

func NewRegistry

func NewRegistry(r *ClientRepository, hasher fosite.Hasher) *Registry

func (*Registry) CreateClient

func (cm *Registry) CreateClient(ctx context.Context, client *Client) (*Client, error)

func (*Registry) DeleteClient

func (cm *Registry) DeleteClient(ctx context.Context, clientID string) error

func (*Registry) GetClient

func (cm *Registry) GetClient(ctx context.Context, clientID string) (*Client, error)

func (*Registry) SetupRoutes

func (cm *Registry) SetupRoutes(mux *http.ServeMux)

func (*Registry) UpsertClient added in v1.51.0

func (cm *Registry) UpsertClient(ctx context.Context, client *Client) (*Client, error)

type UpsertClientParams added in v1.47.0

type UpsertClientParams = sqlcgen.UpsertClientParams

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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