Skip to content

Commit ebaa702

Browse files
matteomazza91wing328
authored andcommitted
feat(security): add cookie-auth support (#240)
1 parent 51437af commit ebaa702

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class CodegenSecurity {
3030
public Map<String, Object> vendorExtensions = new HashMap<String, Object>();
3131
// ApiKey specific
3232
public String keyParamName;
33-
public Boolean isKeyInQuery, isKeyInHeader;
33+
public Boolean isKeyInQuery, isKeyInHeader, isKeyInCookie;
3434
// Oauth specific
3535
public String flow, authorizationUrl, tokenUrl;
3636
public List<Map<String, Object>> scopes;

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,12 +2771,13 @@ public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> securitySc
27712771
cs.isApiKey = true;
27722772
cs.keyParamName = securityScheme.getName();
27732773
cs.isKeyInHeader = securityScheme.getIn() == SecurityScheme.In.HEADER;
2774-
cs.isKeyInQuery = !cs.isKeyInHeader;
2774+
cs.isKeyInQuery = securityScheme.getIn() == SecurityScheme.In.QUERY;
2775+
cs.isKeyInCookie = securityScheme.getIn() == SecurityScheme.In.COOKIE; //it assumes a validation step prior to generation. (cookie-auth supported from OpenAPI 3.0.0)
27752776
} else if (SecurityScheme.Type.HTTP.equals(securityScheme.getType())) {
2776-
cs.isKeyInHeader = cs.isKeyInQuery = cs.isApiKey = cs.isOAuth = false;
2777+
cs.isKeyInHeader = cs.isKeyInQuery = cs.isKeyInCookie = cs.isApiKey = cs.isOAuth = false;
27772778
cs.isBasic = true;
27782779
} else if (SecurityScheme.Type.OAUTH2.equals(securityScheme.getType())) {
2779-
cs.isKeyInHeader = cs.isKeyInQuery = cs.isApiKey = cs.isBasic = false;
2780+
cs.isKeyInHeader = cs.isKeyInQuery = cs.isKeyInCookie = cs.isApiKey = cs.isBasic = false;
27802781
cs.isOAuth = true;
27812782
final OAuthFlows flows = securityScheme.getFlows();
27822783
if (securityScheme.getFlows() == null) {

0 commit comments

Comments
 (0)