-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Ability to assign security schemas (#110)
* Additional types of SecuritySchemeObject. * Adjusting the scopes in SecuritySchemeObject and OAuthFlowObject. * Ref: moving to a separate file. * Distributing by types. * Distributing OAuthFlowsObject. * Add security schemas to the operations with references. * Server level security and changes to config. * Fix: not applying security to emission. * Ref: globalSecurity, testing. * Ref: simpler, simple config has only global security. * Ref: consistency: config sets defaults, NS is always complete. * Readme: feature, Changelog: 1.2.0. * Removing logging in test. * 1.2.0-beta1
- Loading branch information
Showing
15 changed files
with
367 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
interface FlowCommons { | ||
/** @desc The URL to be used for obtaining refresh tokens. */ | ||
refreshUrl?: string; | ||
/** @desc A map between the scope name and a short description for it. */ | ||
availableScopes: Record<string, string>; | ||
} | ||
|
||
interface AuthHavingFlow { | ||
/** @desc The authorization URL to be used for this flow. */ | ||
authorizationUrl: string; | ||
} | ||
|
||
interface TokenHavingFlow { | ||
/** @desc The token URL to be used for this flow. */ | ||
tokenUrl: string; | ||
} | ||
|
||
export interface OAuthFlowsObject { | ||
implicit?: FlowCommons & AuthHavingFlow; | ||
password?: FlowCommons & TokenHavingFlow; | ||
clientCredentials?: FlowCommons & TokenHavingFlow; | ||
authorizationCode?: FlowCommons & AuthHavingFlow & TokenHavingFlow; | ||
} | ||
|
||
interface HttpApiKeySecurity { | ||
type: "httpApiKey"; | ||
/** @desc The name of the header, query or cookie parameter to be used. */ | ||
name: string; | ||
in: "query" | "header" | "cookie"; | ||
} | ||
|
||
interface ApiKeySecurity { | ||
type: "apiKey"; | ||
in: "user" | "password"; | ||
} | ||
|
||
interface HttpSecurity { | ||
type: "http"; | ||
/** @link https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml */ | ||
scheme?: string; | ||
/** @example "Bearer" */ | ||
bearerFormat?: string; | ||
} | ||
|
||
interface ScopesHavingSecurity { | ||
/** @desc List of the needed scope names. An empty array means no scopes are needed. */ | ||
scopes?: string[]; | ||
} | ||
|
||
interface OAuth2Security extends ScopesHavingSecurity { | ||
type: "oauth2"; | ||
flows: OAuthFlowsObject; | ||
} | ||
|
||
interface OpenIdConnectSecurity extends ScopesHavingSecurity { | ||
type: "openIdConnect"; | ||
/** @desc OpenId Connect URL to discover OAuth2 configuration values */ | ||
openIdConnectUrl: string; | ||
} | ||
|
||
interface OtherSecurity { | ||
type: | ||
| "userPassword" | ||
| "X509" | ||
| "symmetricEncryption" | ||
| "asymmetricEncryption" | ||
| "plain" | ||
| "scramSha256" | ||
| "scramSha512" | ||
| "gssapi"; | ||
} | ||
|
||
export type SecuritySchemeObject = { | ||
description?: string; | ||
} & ( | ||
| HttpApiKeySecurity | ||
| ApiKeySecurity | ||
| HttpSecurity | ||
| OAuth2Security | ||
| OpenIdConnectSecurity | ||
| OtherSecurity | ||
); |
Oops, something went wrong.