clientmanager

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientNotFound = errors.New("client not found")
)

Functions

This section is empty.

Types

type ClientMetadata

type ClientMetadata struct {
	ID                      string
	Name                    string
	URI                     string
	RedirectURIs            []string
	GrantTypes              []string
	ResponseTypes           []string
	Scope                   string
	LogoURI                 string
	Contacts                []string
	TermsOfServiceURI       string
	PolicyURI               string
	JSONWebKeysURI          string
	JSONWebKeys             map[string]interface{}
	SoftwareID              string
	SoftwareVersion         string
	TokenEndpointAuthMethod string
}

ClientMetadata contains the metadata for an OAuth2 client.

type Config

type Config struct {
	Store          store
	ProfileService profileService
}

Config defines configuration for client manager.

type ErrorCode

type ErrorCode string

ErrorCode is an error code for client registration error response as defined in https://datatracker.ietf.org/doc/html/rfc7591#section-3.2.2.

const (
	// ErrCodeInvalidRedirectURI defines error case when the value of one or more redirection URIs is invalid.
	ErrCodeInvalidRedirectURI ErrorCode = "invalid_redirect_uri"
	// ErrCodeInvalidClientMetadata defines error case when the value of one of the client metadata fields is invalid
	// and the server has rejected this request.
	ErrCodeInvalidClientMetadata ErrorCode = "invalid_client_metadata"
	// ErrCodeInvalidSoftwareStatement defines error case when the software statement presented is invalid.
	ErrCodeInvalidSoftwareStatement ErrorCode = "invalid_software_statement"
	// ErrCodeUnapprovedSoftwareStatement defines error case when the software statement presented is not approved for
	// use by the server.
	ErrCodeUnapprovedSoftwareStatement ErrorCode = "unapproved_software_statement"
)

type Manager

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

Manager implements functionality to manage OAuth2 clients.

func New

func New(config *Config) *Manager

New creates a new Manager instance.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, profileID, profileVersion string, data *ClientMetadata) (*oauth2client.Client, error)

Create creates an OAuth2 client and inserts it into the store.

func (*Manager) Get added in v1.2.0

func (m *Manager) Get(ctx context.Context, id string) (fosite.Client, error)

Get returns the fosite client with the given id.

type RegistrationError

type RegistrationError struct {
	Code         ErrorCode `json:"error"`
	InvalidValue string    `json:"invalid_value,omitempty"`
	Err          error     `json:"-"` // wrapped error
}

RegistrationError defines a registration error in client registration response. When a registration error occurs, the server returns an HTTP 400 status code.

func InvalidClientMetadataError

func InvalidClientMetadataError(invalidValue string, err error) *RegistrationError

InvalidClientMetadataError creates a new RegistrationError with ErrCodeInvalidClientMetadata error code.

func (*RegistrationError) Error

func (r *RegistrationError) Error() string

Error returns a string representation of the error.

type ServiceInterface

type ServiceInterface interface {
	Create(ctx context.Context, profileID, profileVersion string, data *ClientMetadata) (*oauth2client.Client, error)
	Get(ctx context.Context, id string) (fosite.Client, error)
}

ServiceInterface defines an interface for OAuth2 client manager.

Jump to

Keyboard shortcuts

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