Versions in this module Expand all Collapse all v0 v0.1.1 Nov 12, 2026 Changes in this version type Plugin + func (p *Plugin) ServeOperation(id auth.EndpointID, opts ...authhttp.Option) http.Handler v0.1.0 Oct 14, 2026 Changes in this version + const ColClientID + const ColCreatedAt + const ColDeviceCodeHash + const ColExpiresAt + const ColGrant + const ColID + const ColLastPolledAt + const ColPollingInterval + const ColResource + const ColScope + const ColStatus + const ColUserCodeHash + const ColUserID + const DefaultDeviceCodeLength + const DefaultExpiresIn + const DefaultInterval + const DefaultUserCodeLength + const DefaultVerificationURI + const EndpointApprove + const EndpointCode + const EndpointDeny + const EndpointToken + const EndpointVerify + const GrantType + const MaxCodeLength + const PluginName + const RFCAccessDenied + const RFCAuthorizationPending + const RFCExpiredToken + const RFCInvalidClient + const RFCInvalidGrant + const RFCInvalidRequest + const RFCInvalidTarget + const RFCServerError + const RFCSlowDown + const RFCTemporarilyUnavailable + const RFCUnsupportedGrantType + const SlowDownStep + const TableAliasCode + const TableNameCode + const TokenType + const UserCodeAlphabet + var CodeClientID = sqlb.Col[string](TableCode, ColClientID) + var CodeCreatedAt = sqlb.Col[time.Time](TableCode, ColCreatedAt) + var CodeDeviceCodeHash = sqlb.Col[[]byte](TableCode, ColDeviceCodeHash) + var CodeExpiresAt = sqlb.Col[time.Time](TableCode, ColExpiresAt) + var CodeGrant = sqlb.Col[*string](TableCode, ColGrant) + var CodeID = sqlb.Col[string](TableCode, ColID) + var CodeLastPolledAt = sqlb.Col[*time.Time](TableCode, ColLastPolledAt) + var CodePollingInterval = sqlb.Col[int64](TableCode, ColPollingInterval) + var CodeResource = sqlb.Col[*string](TableCode, ColResource) + var CodeScope = sqlb.Col[string](TableCode, ColScope) + var CodeStatus = sqlb.Col[Status](TableCode, ColStatus) + var CodeUserCodeHash = sqlb.Col[[]byte](TableCode, ColUserCodeHash) + var CodeUserID = sqlb.Col[*string](TableCode, ColUserID) + var ErrAccessDenied = auth.NewError("device.access_denied", http.StatusBadRequest, "The user denied the request.") + var ErrAlreadyProcessed = auth.NewError("device.already_processed", http.StatusBadRequest, ...) + var ErrAuthorizationPending = auth.NewError("device.authorization_pending", http.StatusBadRequest, ...) + var ErrBadExpiresIn = errors.New("deviceauth: WithExpiresIn needs a positive duration") + var ErrBadInterval = errors.New("deviceauth: WithInterval needs a positive duration") + var ErrBadLength = fmt.Errorf("deviceauth: code lengths must be 1 to %d", MaxCodeLength) + var ErrBadLimit = errors.New("deviceauth: WithVerifyLimit needs a positive limit and window") + var ErrClientConfig = errors.New("deviceauth: a Client needs CodeURL, TokenURL and ClientID") + var ErrExpiredDeviceCode = auth.NewError("device.expired_device_code", http.StatusBadRequest, ...) + var ErrExpiredUserCode = auth.NewError("device.expired_user_code", http.StatusBadRequest, ...) + var ErrInvalidClient = auth.NewError("device.invalid_client", http.StatusBadRequest, ...) + var ErrInvalidDeviceCode = auth.NewError("device.invalid_device_code", http.StatusBadRequest, ...) + var ErrInvalidRequest = auth.NewError("device.invalid_request", http.StatusBadRequest, ...) + var ErrInvalidUserCode = auth.NewError("device.invalid_user_code", http.StatusBadRequest, ...) + var ErrNotClaimed = auth.NewError("device.not_claimed", http.StatusBadRequest, ...) + var ErrNotOwner = auth.NewError("device.not_owner", http.StatusForbidden, ...) + var ErrPollingTooFrequently = auth.NewError("device.polling_too_frequently", http.StatusBadRequest, ...) + var ErrServerError = auth.NewError("device.server_error", http.StatusInternalServerError, ...) + var ErrUnsupportedGrantType = auth.NewError("device.unsupported_grant_type", http.StatusBadRequest, ...) + var StatusValues = []Status + var TableCode = sqlb.Table + func NormalizeUserCode(code string) string + func RFCErrorCode(err error) string + type Binding struct + Grant string + Resource string + Scope string + type Client struct + ClientID string + CodeURL string + HTTP *http.Client + Sleep func(ctx context.Context, d time.Duration) error + TokenURL string + func (c *Client) Poll(ctx context.Context, code CodeResult) (TokenResult, error) + func (c *Client) RequestCode(ctx context.Context, scope string) (CodeResult, error) + type ClientError struct + Description string + ErrorName string + Status int + func (e *ClientError) Error() string + type CodeRequest struct + ClientAssertion string + ClientAssertionType string + ClientID string + ClientSecret string + Resource string + Scope string + UserID string + type CodeResult struct + DeviceCode string + ExpiresIn int + Interval int + UserCode string + VerificationURI string + VerificationURIComplete string + type DecisionRequest struct + UserCode string + type DecisionResult struct + Success bool + type Generator func(ctx context.Context) (string, error) + type Grant interface + AuthorizeCode func(ctx context.Context, c *auth.Call, in CodeRequest) (Binding, error) + type Option func(*Plugin) + func DeviceCodeLength(n int) Option + func GenerateDeviceCode(fn Generator) Option + func GenerateUserCode(fn Generator) Option + func OnDeviceAuthRequest(fn func(ctx context.Context, clientID, scope string) error) Option + func UserCodeLength(n int) Option + func ValidateClient(fn func(ctx context.Context, clientID string) (bool, error)) Option + func VerificationURI(u string) Option + func WithExpiresIn(d time.Duration) Option + func WithGrant(g Grant) Option + func WithInterval(d time.Duration) Option + func WithVerifyLimit(n int, window time.Duration) Option + type Plugin struct + func New(opts ...Option) *Plugin + func (p *Plugin) Approve(ctx context.Context, userCode string) error + func (p *Plugin) Code(ctx context.Context, in CodeRequest) (CodeResult, error) + func (p *Plugin) CodeHandler(opts ...authhttp.Option) http.Handler + func (p *Plugin) Deny(ctx context.Context, userCode string) error + func (p *Plugin) Init(a *auth.Auth) error + func (p *Plugin) Name() string + func (p *Plugin) Operations() []auth.Operation + func (p *Plugin) OptionErr() error + func (p *Plugin) RateLimits() []auth.RateRule + func (p *Plugin) Redeem(ctx context.Context, deviceCode, clientID, grant string) (Redemption, error) + func (p *Plugin) Sweep(ctx context.Context, cutoff time.Time) (int64, error) + func (p *Plugin) Tables() []sqlb.Table + func (p *Plugin) Token(ctx context.Context, in TokenRequest) (TokenResult, error) + func (p *Plugin) TokenHandler(opts ...authhttp.Option) http.Handler + func (p *Plugin) TypedMigrations(engine string, t auth.SQLTypes) ([]auth.Migration, error) + func (p *Plugin) UserTables() []auth.UserTable + func (p *Plugin) Validate(*auth.Config) error + func (p *Plugin) Verify(ctx context.Context, userCode string) (VerifyResult, error) + type RFCCoder interface + RFCCode func() string + type Redemption struct + Resource string + Scope string + UserID string + type Status string + const StatusApproved + const StatusDenied + const StatusPending + type TokenRequest struct + ClientID string + DeviceCode string + GrantType string + type TokenResult struct + AccessToken string + ExpiresIn int + Scope string + TokenType string + UserID string + type VerifyRequest struct + UserCode string + type VerifyResult struct + ClientID string + Owned bool + Resource string + Scope string + Status Status + UserCode string