securityscheme

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeApiKey identifies an apiKey security scheme.
	TypeApiKey = "apiKey"
	// TypeHTTP identifies an http security scheme.
	TypeHTTP = "http"
	// TypeOAuth2 identifies an oauth2 security scheme.
	TypeOAuth2 = "oauth2"
	// TypeOpenIdConnect identifies an openIdConnect security scheme.
	TypeOpenIdConnect = "openIdConnect"

	// InHeader identifies a header API key location.
	InHeader = "header"
	// InQuery identifies a query API key location.
	InQuery = "query"
	// InCookie identifies a cookie API key location.
	InCookie = "cookie"
)

Variables

This section is empty.

Functions

func New

func New(store *store.Store, name string, opts ...Option) *v3.SecurityScheme

New creates a new security scheme. The scheme is stored in components/securitySchemes under name.

Types

type OAuthFlowOption

type OAuthFlowOption func(*v3.OAuthFlow)

OAuthFlowOption configures a single OAuth2 flow.

func FlowRefreshUrl

func FlowRefreshUrl(url string) OAuthFlowOption

FlowRefreshUrl sets the refresh URL for the OAuth2 flow.

func FlowScope

func FlowScope(name, description string) OAuthFlowOption

FlowScope adds a scope to the OAuth2 flow.

type OAuthFlowsOption

type OAuthFlowsOption func(*v3.OAuthFlows)

OAuthFlowsOption configures the OAuth2 flows object.

func FlowAuthorizationCode

func FlowAuthorizationCode(authorizationUrl, tokenUrl string, opts ...OAuthFlowOption) OAuthFlowsOption

FlowAuthorizationCode configures the OAuth2 authorization code flow.

func FlowClientCredentials

func FlowClientCredentials(tokenUrl string, opts ...OAuthFlowOption) OAuthFlowsOption

FlowClientCredentials configures the OAuth2 client credentials flow.

func FlowDevice

func FlowDevice(tokenUrl string, opts ...OAuthFlowOption) OAuthFlowsOption

FlowDevice configures the OAuth2 device authorization flow (OpenAPI 3.2+).

func FlowImplicit

func FlowImplicit(authorizationUrl string, opts ...OAuthFlowOption) OAuthFlowsOption

FlowImplicit configures the OAuth2 implicit flow.

func FlowPassword

func FlowPassword(tokenUrl string, opts ...OAuthFlowOption) OAuthFlowsOption

FlowPassword configures the OAuth2 resource owner password flow.

type Option

type Option func(*v3.SecurityScheme)

Option configures an OpenAPI security scheme.

func ApiKey

func ApiKey(in, name string) Option

ApiKey sets an "apiKey" security scheme type. in must be "header", "query", or "cookie".

func BearerFormat

func BearerFormat(s string) Option

BearerFormat sets a hint for the bearer token format, e.g. "JWT".

func Deprecated

func Deprecated() Option

Deprecated marks the security scheme as deprecated (OpenAPI 3.2+).

func Description

func Description(s string) Option

Description sets the security scheme description.

func Flows

func Flows(opts ...OAuthFlowsOption) Option

Flows sets the OAuth2 flows for the security scheme.

func HTTP

func HTTP(scheme string) Option

HTTP sets an "http" security scheme type. scheme is the HTTP Authorization scheme name (e.g. "bearer", "basic").

func In

func In(s string) Option

In sets the location of the API key. Must be "header", "query", or "cookie".

func Name

func Name(s string) Option

Name sets the name of the header, query, or cookie parameter for apiKey schemes.

func OAuth2MetadataUrl

func OAuth2MetadataUrl(url string) Option

OAuth2MetadataUrl sets the OAuth2 metadata URL (OpenAPI 3.2+).

func OpenIdConnectUrl

func OpenIdConnectUrl(url string) Option

OpenIdConnectUrl sets the OpenID Connect discovery URL.

func Reference

func Reference(name string) Option

Reference sets a $ref to a named security scheme in components/securitySchemes.

func Scheme

func Scheme(s string) Option

Scheme sets the HTTP Authorization scheme name (e.g. "bearer", "basic").

func Type

func Type(s string) Option

Type sets the security scheme type.

Jump to

Keyboard shortcuts

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