auth

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package auth provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthorizeRequest

func NewAuthorizeRequest(server string, params *AuthorizeParams) (*http.Request, error)

NewAuthorizeRequest generates requests for Authorize

func NewRevokeRequestWithBody

func NewRevokeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewRevokeRequestWithBody generates requests for Revoke with any type of body

func NewRevokeRequestWithFormdataBody

func NewRevokeRequestWithFormdataBody(server string, body RevokeFormdataRequestBody) (*http.Request, error)

NewRevokeRequestWithFormdataBody calls the generic Revoke builder with application/x-www-form-urlencoded body

func NewTokenRequestWithBody

func NewTokenRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewTokenRequestWithBody generates requests for Token with any type of body

func NewTokenRequestWithFormdataBody

func NewTokenRequestWithFormdataBody(server string, body TokenFormdataRequestBody) (*http.Request, error)

NewTokenRequestWithFormdataBody calls the generic Token builder with application/x-www-form-urlencoded body

Types

type AuthorizeHTTPResp

type AuthorizeHTTPResp struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON400      *OAuth2Error
}

func ParseAuthorizeHTTPResp

func ParseAuthorizeHTTPResp(rsp *http.Response) (*AuthorizeHTTPResp, error)

ParseAuthorizeHTTPResp parses an HTTP response from a AuthorizeWithResponse call

func (AuthorizeHTTPResp) Status

func (r AuthorizeHTTPResp) Status() string

Status returns HTTPResponse.Status

func (AuthorizeHTTPResp) StatusCode

func (r AuthorizeHTTPResp) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type AuthorizeParams

type AuthorizeParams struct {
	// ResponseType Must be `code` for the Authorization Code flow.
	ResponseType AuthorizeParamsResponseType `form:"response_type" json:"response_type"`
	ClientId     string                      `form:"client_id" json:"client_id"`

	// RedirectUri Must exactly match the client's registered callback URL.
	RedirectUri string `form:"redirect_uri" json:"redirect_uri"`

	// Scope Requested scope, e.g. `*` for all access.
	Scope string `form:"scope" json:"scope"`

	// State Opaque value returned unchanged in the redirect; use it for CSRF protection.
	State *string `form:"state,omitempty" json:"state,omitempty"`

	// CodeChallenge PKCE code challenge (RFC 7636). Required for public clients.
	CodeChallenge *string `form:"code_challenge,omitempty" json:"code_challenge,omitempty"`

	// CodeChallengeMethod PKCE transformation. `S256` is strongly recommended.
	CodeChallengeMethod *AuthorizeParamsCodeChallengeMethod `form:"code_challenge_method,omitempty" json:"code_challenge_method,omitempty"`
}

AuthorizeParams defines parameters for Authorize.

type AuthorizeParamsCodeChallengeMethod

type AuthorizeParamsCodeChallengeMethod string

AuthorizeParamsCodeChallengeMethod defines parameters for Authorize.

Defines values for AuthorizeParamsCodeChallengeMethod.

type AuthorizeParamsResponseType

type AuthorizeParamsResponseType string

AuthorizeParamsResponseType defines parameters for Authorize.

const (
	Code AuthorizeParamsResponseType = "code"
)

Defines values for AuthorizeParamsResponseType.

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context, params *AuthorizeParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) RevokeWithBody

func (c *Client) RevokeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) RevokeWithFormdataBody

func (c *Client) RevokeWithFormdataBody(ctx context.Context, body RevokeFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) TokenWithBody

func (c *Client) TokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) TokenWithFormdataBody

func (c *Client) TokenWithFormdataBody(ctx context.Context, body TokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// Authorize request
	Authorize(ctx context.Context, params *AuthorizeParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// RevokeWithBody request with any body
	RevokeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	RevokeWithFormdataBody(ctx context.Context, body RevokeFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// TokenWithBody request with any body
	TokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	TokenWithFormdataBody(ctx context.Context, body TokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) AuthorizeWithResponse

func (c *ClientWithResponses) AuthorizeWithResponse(ctx context.Context, params *AuthorizeParams, reqEditors ...RequestEditorFn) (*AuthorizeHTTPResp, error)

AuthorizeWithResponse request returning *AuthorizeHTTPResp

func (*ClientWithResponses) RevokeWithBodyWithResponse

func (c *ClientWithResponses) RevokeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RevokeHTTPResp, error)

RevokeWithBodyWithResponse request with arbitrary body returning *RevokeHTTPResp

func (*ClientWithResponses) RevokeWithFormdataBodyWithResponse

func (c *ClientWithResponses) RevokeWithFormdataBodyWithResponse(ctx context.Context, body RevokeFormdataRequestBody, reqEditors ...RequestEditorFn) (*RevokeHTTPResp, error)

func (*ClientWithResponses) TokenWithBodyWithResponse

func (c *ClientWithResponses) TokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TokenHTTPResp, error)

TokenWithBodyWithResponse request with arbitrary body returning *TokenHTTPResp

func (*ClientWithResponses) TokenWithFormdataBodyWithResponse

func (c *ClientWithResponses) TokenWithFormdataBodyWithResponse(ctx context.Context, body TokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*TokenHTTPResp, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// AuthorizeWithResponse request
	AuthorizeWithResponse(ctx context.Context, params *AuthorizeParams, reqEditors ...RequestEditorFn) (*AuthorizeHTTPResp, error)

	// RevokeWithBodyWithResponse request with any body
	RevokeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RevokeHTTPResp, error)

	RevokeWithFormdataBodyWithResponse(ctx context.Context, body RevokeFormdataRequestBody, reqEditors ...RequestEditorFn) (*RevokeHTTPResp, error)

	// TokenWithBodyWithResponse request with any body
	TokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TokenHTTPResp, error)

	TokenWithFormdataBodyWithResponse(ctx context.Context, body TokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*TokenHTTPResp, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type OAuth2Error

type OAuth2Error struct {
	// Error RFC 6749 error code, e.g. invalid_grant, invalid_client, invalid_request.
	Error            string  `json:"error"`
	ErrorDescription *string `json:"error_description,omitempty"`

	// State Echoed from the request when present.
	State *string `json:"state,omitempty"`
}

OAuth2Error defines model for OAuth2Error.

type OAuthRevokeRequest

type OAuthRevokeRequest struct {
	// ClientId Optional; validated when supplied.
	ClientId *string `json:"client_id,omitempty"`

	// ClientSecret Required with client_id for confidential clients.
	ClientSecret *string `json:"client_secret,omitempty"`

	// Token The access_token or refresh_token to revoke.
	Token string `json:"token"`

	// TokenTypeHint Optional optimization hint (RFC 7009 §2.1).
	TokenTypeHint *OAuthRevokeRequestTokenTypeHint `json:"token_type_hint,omitempty"`
}

OAuthRevokeRequest defines model for OAuthRevokeRequest.

type OAuthRevokeRequestTokenTypeHint

type OAuthRevokeRequestTokenTypeHint string

OAuthRevokeRequestTokenTypeHint Optional optimization hint (RFC 7009 §2.1).

const (
	OAuthRevokeRequestTokenTypeHintAccessToken  OAuthRevokeRequestTokenTypeHint = "access_token"
	OAuthRevokeRequestTokenTypeHintRefreshToken OAuthRevokeRequestTokenTypeHint = "refresh_token"
)

Defines values for OAuthRevokeRequestTokenTypeHint.

type OAuthTokenRequest

type OAuthTokenRequest struct {
	// AccessType `offline` (default for authorization_code) also returns a refresh_token.
	AccessType *OAuthTokenRequestAccessType `json:"access_type,omitempty"`

	// ClientId Required for `authorization_code` and `client_credentials`.
	ClientId *string `json:"client_id,omitempty"`

	// ClientSecret Required for confidential clients; omitted by public clients (which use PKCE).
	ClientSecret *string `json:"client_secret,omitempty"`

	// Code `authorization_code` only — the code returned by /oauth/authorize.
	Code *string `json:"code,omitempty"`

	// CodeVerifier `authorization_code` with PKCE (RFC 7636) — required for public clients.
	CodeVerifier *string `json:"code_verifier,omitempty"`

	// GrantType The OAuth 2.0 grant type.
	GrantType OAuthTokenRequestGrantType `json:"grant_type"`

	// Password `password` only — the user's password.
	Password *string `json:"password,omitempty"`

	// RedirectUri `authorization_code` only — must match the value used at /oauth/authorize.
	RedirectUri *string `json:"redirect_uri,omitempty"`

	// RefreshToken `refresh_token` only — the most recently issued refresh token (rotated each use).
	RefreshToken *string `json:"refresh_token,omitempty"`

	// Scope Requested scope. For `authorization_code` the scope bound to the code always wins.
	Scope *string `json:"scope,omitempty"`

	// Username `password` only — the user's email/username.
	Username *string `json:"username,omitempty"`
}

OAuthTokenRequest defines model for OAuthTokenRequest.

type OAuthTokenRequestAccessType

type OAuthTokenRequestAccessType string

OAuthTokenRequestAccessType `offline` (default for authorization_code) also returns a refresh_token.

const (
	Offline OAuthTokenRequestAccessType = "offline"
	Online  OAuthTokenRequestAccessType = "online"
)

Defines values for OAuthTokenRequestAccessType.

type OAuthTokenRequestGrantType

type OAuthTokenRequestGrantType string

OAuthTokenRequestGrantType The OAuth 2.0 grant type.

const (
	OAuthTokenRequestGrantTypeAuthorizationCode OAuthTokenRequestGrantType = "authorization_code"
	OAuthTokenRequestGrantTypeClientCredentials OAuthTokenRequestGrantType = "client_credentials"
	OAuthTokenRequestGrantTypePassword          OAuthTokenRequestGrantType = "password"
	OAuthTokenRequestGrantTypeRefreshToken      OAuthTokenRequestGrantType = "refresh_token"
)

Defines values for OAuthTokenRequestGrantType.

type OAuthTokenResponse

type OAuthTokenResponse struct {
	AccessToken string  `json:"access_token"`
	ClientId    *string `json:"client_id,omitempty"`

	// ExpiresIn Lifetime in seconds. Omitted for non-expiring tokens.
	ExpiresIn *int64 `json:"expires_in,omitempty"`

	// RefreshToken Present when a refresh token was issued (rotated on every refresh).
	RefreshToken *string `json:"refresh_token,omitempty"`
	Scope        *string `json:"scope,omitempty"`
	TokenType    string  `json:"token_type"`
}

OAuthTokenResponse defines model for OAuthTokenResponse.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type RevokeFormdataRequestBody

type RevokeFormdataRequestBody = OAuthRevokeRequest

RevokeFormdataRequestBody defines body for Revoke for application/x-www-form-urlencoded ContentType.

type RevokeHTTPResp

type RevokeHTTPResp struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *map[string]interface{}
	JSON400      *OAuth2Error
}

func ParseRevokeHTTPResp

func ParseRevokeHTTPResp(rsp *http.Response) (*RevokeHTTPResp, error)

ParseRevokeHTTPResp parses an HTTP response from a RevokeWithResponse call

func (RevokeHTTPResp) Status

func (r RevokeHTTPResp) Status() string

Status returns HTTPResponse.Status

func (RevokeHTTPResp) StatusCode

func (r RevokeHTTPResp) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type TokenFormdataRequestBody

type TokenFormdataRequestBody = OAuthTokenRequest

TokenFormdataRequestBody defines body for Token for application/x-www-form-urlencoded ContentType.

type TokenHTTPResp

type TokenHTTPResp struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *OAuthTokenResponse
	JSON400      *OAuth2Error
}

func ParseTokenHTTPResp

func ParseTokenHTTPResp(rsp *http.Response) (*TokenHTTPResp, error)

ParseTokenHTTPResp parses an HTTP response from a TokenWithResponse call

func (TokenHTTPResp) Status

func (r TokenHTTPResp) Status() string

Status returns HTTPResponse.Status

func (TokenHTTPResp) StatusCode

func (r TokenHTTPResp) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

Jump to

Keyboard shortcuts

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