Skip to content

Commit

Permalink
feat(security): add cookie-auth support (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
matteomazza91 authored and wing328 committed Jun 8, 2018
1 parent 51437af commit ebaa702
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CodegenSecurity {
public Map<String, Object> vendorExtensions = new HashMap<String, Object>();
// ApiKey specific
public String keyParamName;
public Boolean isKeyInQuery, isKeyInHeader;
public Boolean isKeyInQuery, isKeyInHeader, isKeyInCookie;
// Oauth specific
public String flow, authorizationUrl, tokenUrl;
public List<Map<String, Object>> scopes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2771,12 +2771,13 @@ public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> securitySc
cs.isApiKey = true;
cs.keyParamName = securityScheme.getName();
cs.isKeyInHeader = securityScheme.getIn() == SecurityScheme.In.HEADER;
cs.isKeyInQuery = !cs.isKeyInHeader;
cs.isKeyInQuery = securityScheme.getIn() == SecurityScheme.In.QUERY;
cs.isKeyInCookie = securityScheme.getIn() == SecurityScheme.In.COOKIE; //it assumes a validation step prior to generation. (cookie-auth supported from OpenAPI 3.0.0)
} else if (SecurityScheme.Type.HTTP.equals(securityScheme.getType())) {
cs.isKeyInHeader = cs.isKeyInQuery = cs.isApiKey = cs.isOAuth = false;
cs.isKeyInHeader = cs.isKeyInQuery = cs.isKeyInCookie = cs.isApiKey = cs.isOAuth = false;
cs.isBasic = true;
} else if (SecurityScheme.Type.OAUTH2.equals(securityScheme.getType())) {
cs.isKeyInHeader = cs.isKeyInQuery = cs.isApiKey = cs.isBasic = false;
cs.isKeyInHeader = cs.isKeyInQuery = cs.isKeyInCookie = cs.isApiKey = cs.isBasic = false;
cs.isOAuth = true;
final OAuthFlows flows = securityScheme.getFlows();
if (securityScheme.getFlows() == null) {
Expand Down

0 comments on commit ebaa702

Please sign in to comment.