security

package
v2.932.8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreOAuth2ScopeSetsEqual

func AreOAuth2ScopeSetsEqual(left, right []string) bool

AreOAuth2ScopeSetsEqual reports whether two OAuth2 scope lists contain the same distinct scopes. Scope order and duplicate entries do not change the security requirement's meaning.

func GetOAuth2FlowConfig

func GetOAuth2FlowConfig(ctx context.Context, schemeKey string, s *openapi.ReferencedSecurityScheme, opts *Opts) (*ast.OAuth2FlowConfig, error)

GetOAuth2FlowConfig will return the OAuth2 flow configuration for a given security scheme, which includes available scopes and whether the flow is enabled or not.

func GetSecuritySchemeTypeDef

func GetSecuritySchemeTypeDef(ctx context.Context, scheme *openapi.SecurityScheme, schemeKey string, docInfo *document.DocumentInfo, opts *Opts) (*ast.TypeDef, error)

Returns the registered TypeDef of the security scheme.

func HandlePerOpSecurity

func HandlePerOpSecurity(ctx context.Context, opts HandlePerOpSecurityOpts) (*ast.Security, error)

func IsOAuth2ClientCredentialsEnabled

func IsOAuth2ClientCredentialsEnabled(ctx context.Context, subsystem *subsystem.Subsystem) bool

Returns true if the OAuth2 Client Credentials flow is enabled by checking:

  • If the account has access to the oauth2ClientCredentials feature.
  • If the target supports the oauth2ClientCredentials feature.
  • If the generation configuration has auth.oAuth2ClientCredentialsEnabled enabled.

func IsOAuth2PasswordEnabled

func IsOAuth2PasswordEnabled(ctx context.Context, subsystem *subsystem.Subsystem) bool

Returns true if the OAuth2 Resource Owner Password flow is enabled by checking: - If the account has access to the oauth2Password feature. - If the target supports the oauth2Password feature. - If the generation configuration has auth.oAuth2PasswordEnabled enabled.

func IsSecurityDisabled

func IsSecurityDisabled(securityReqs []*openapi.SecurityRequirement) bool

Types

type GlobalSecurityHoistMap

type GlobalSecurityHoistMap map[string]ast.HoistedSecurityField

type GlobalSecurityMatcher

type GlobalSecurityMatcher func(opReqs []ast.SecurityRequirement, optional bool) (equivalent bool, hoistedFields []ast.HoistedSecurityField)

GlobalSecurityMatcher checks whether an operation's security requirements match the global security options. If all requirements defined on the operation are already present at the global level, the operation security is no longer needed (i.e. can be hoisted). In this case the matching global security fields are returned in the priority order defined by the operation. If the operation cannot be hoisted, the matcher returns (false, nil). If the operation security is equivalent to the global security (i.e. no filtering or reordering is needed) the matcher returns (true, [..]) Built once per generation via NewGlobalSecurityMatcher and reused across all operations. Nil when global=true.

func NewGlobalSecurityMatcher

func NewGlobalSecurityMatcher(globalSecurity *ast.Security) GlobalSecurityMatcher

NewGlobalSecurityMatcher builds a GlobalSecurityMatcher based on the SDK's global security. Returns nil if globalSecurity is nil or has no requirements.

type HandleGlobalSecurityOptions

type HandleGlobalSecurityOptions struct {
	Opts
}

type HandlePerOpSecurityOpts

type HandlePerOpSecurityOpts struct {
	Opts
	ContextStack          ast.ContextStack
	SecurityReqs          []*openapi.SecurityRequirement
	SecuritySchemes       *sequencedmap.Map[string, *openapi.ReferencedSecurityScheme]
	Optional              ast.SecurityOptionalityReason
	GlobalSecurityMatcher GlobalSecurityMatcher
	Scope                 ast.Scope
	DocInfo               *document.DocumentInfo
}

type Opts

type Opts struct {
	Subsystem *subsystem.Subsystem
	Schemas   *schemas.Schemas
	DocInfo   *document.DocumentInfo
}

type SchemeNameOverrides

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

func (SchemeNameOverrides) ResolveOriginalKey

func (o SchemeNameOverrides) ResolveOriginalKey(schemeKey string) string

func (SchemeNameOverrides) ResolveSchemeKey

func (o SchemeNameOverrides) ResolveSchemeKey(originalKey string) string

Jump to

Keyboard shortcuts

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