@@ -28,13 +28,14 @@ var _ jsonpointer.JSONPointable = (*SecuritySchemes)(nil)
2828type SecurityScheme struct {
2929 ExtensionProps
3030
31- Type string `json:"type,omitempty" yaml:"type,omitempty"`
32- Description string `json:"description,omitempty" yaml:"description,omitempty"`
33- Name string `json:"name,omitempty" yaml:"name,omitempty"`
34- In string `json:"in,omitempty" yaml:"in,omitempty"`
35- Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
36- BearerFormat string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"`
37- Flows * OAuthFlows `json:"flows,omitempty" yaml:"flows,omitempty"`
31+ Type string `json:"type,omitempty" yaml:"type,omitempty"`
32+ Description string `json:"description,omitempty" yaml:"description,omitempty"`
33+ Name string `json:"name,omitempty" yaml:"name,omitempty"`
34+ In string `json:"in,omitempty" yaml:"in,omitempty"`
35+ Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
36+ BearerFormat string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"`
37+ Flows * OAuthFlows `json:"flows,omitempty" yaml:"flows,omitempty"`
38+ OpenIdConnectUrl string `json:"openIdConnectUrl,omitempty" yaml:"openIdConnectUrl,omitempty"`
3839}
3940
4041func NewSecurityScheme () * SecurityScheme {
@@ -49,6 +50,13 @@ func NewCSRFSecurityScheme() *SecurityScheme {
4950 }
5051}
5152
53+ func NewOIDCSecurityScheme (oidcUrl string ) * SecurityScheme {
54+ return & SecurityScheme {
55+ Type : "openIdConnect" ,
56+ OpenIdConnectUrl : oidcUrl ,
57+ }
58+ }
59+
5260func NewJWTSecurityScheme () * SecurityScheme {
5361 return & SecurityScheme {
5462 Type : "http" ,
@@ -114,7 +122,9 @@ func (ss *SecurityScheme) Validate(c context.Context) error {
114122 case "oauth2" :
115123 hasFlow = true
116124 case "openIdConnect" :
117- return fmt .Errorf ("Support for security schemes with type '%v' has not been implemented" , ss .Type )
125+ if ss .OpenIdConnectUrl == "" {
126+ return fmt .Errorf ("No OIDC URL found for openIdConnect security scheme %q" , ss .Name )
127+ }
118128 default :
119129 return fmt .Errorf ("Security scheme 'type' can't be '%v'" , ss .Type )
120130 }
0 commit comments