-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19680 from phillip-kruger/openapi-autosecurity
OpenAPI Auto security based on extensions
- Loading branch information
Showing
14 changed files
with
486 additions
and
16 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
37 changes: 37 additions & 0 deletions
37
...ime/src/main/java/io/quarkus/smallrye/openapi/runtime/filter/AutoBasicSecurityFilter.java
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,37 @@ | ||
package io.quarkus.smallrye.openapi.runtime.filter; | ||
|
||
import org.eclipse.microprofile.openapi.OASFactory; | ||
import org.eclipse.microprofile.openapi.models.security.SecurityScheme; | ||
|
||
/** | ||
* Add Basic Authentication security automatically based on the added security extensions | ||
*/ | ||
public class AutoBasicSecurityFilter extends AutoSecurityFilter { | ||
private String basicSecuritySchemeValue; | ||
|
||
public AutoBasicSecurityFilter() { | ||
super(); | ||
} | ||
|
||
public AutoBasicSecurityFilter(String securitySchemeName, String securitySchemeDescription, | ||
String basicSecuritySchemeValue) { | ||
super(securitySchemeName, securitySchemeDescription); | ||
this.basicSecuritySchemeValue = basicSecuritySchemeValue; | ||
} | ||
|
||
public String getBasicSecuritySchemeValue() { | ||
return basicSecuritySchemeValue; | ||
} | ||
|
||
public void setBasicSecuritySchemeValue(String basicSecuritySchemeValue) { | ||
this.basicSecuritySchemeValue = basicSecuritySchemeValue; | ||
} | ||
|
||
@Override | ||
protected SecurityScheme getSecurityScheme() { | ||
SecurityScheme securityScheme = OASFactory.createSecurityScheme(); | ||
securityScheme.setType(SecurityScheme.Type.HTTP); | ||
securityScheme.setScheme(basicSecuritySchemeValue); | ||
return securityScheme; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...ntime/src/main/java/io/quarkus/smallrye/openapi/runtime/filter/AutoJWTSecurityFilter.java
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,48 @@ | ||
package io.quarkus.smallrye.openapi.runtime.filter; | ||
|
||
import org.eclipse.microprofile.openapi.OASFactory; | ||
import org.eclipse.microprofile.openapi.models.security.SecurityScheme; | ||
|
||
/** | ||
* Add JWT Authentication security automatically based on the added security extensions | ||
*/ | ||
public class AutoJWTSecurityFilter extends AutoSecurityFilter { | ||
private String jwtSecuritySchemeValue; | ||
private String jwtBearerFormat; | ||
|
||
public AutoJWTSecurityFilter() { | ||
super(); | ||
} | ||
|
||
public AutoJWTSecurityFilter(String securitySchemeName, String securitySchemeDescription, String jwtSecuritySchemeValue, | ||
String jwtBearerFormat) { | ||
super(securitySchemeName, securitySchemeDescription); | ||
this.jwtSecuritySchemeValue = jwtSecuritySchemeValue; | ||
this.jwtBearerFormat = jwtBearerFormat; | ||
} | ||
|
||
public String getJwtSecuritySchemeValue() { | ||
return jwtSecuritySchemeValue; | ||
} | ||
|
||
public void setJwtSecuritySchemeValue(String jwtSecuritySchemeValue) { | ||
this.jwtSecuritySchemeValue = jwtSecuritySchemeValue; | ||
} | ||
|
||
public String getJwtBearerFormat() { | ||
return jwtBearerFormat; | ||
} | ||
|
||
public void setJwtBearerFormat(String jwtBearerFormat) { | ||
this.jwtBearerFormat = jwtBearerFormat; | ||
} | ||
|
||
@Override | ||
protected SecurityScheme getSecurityScheme() { | ||
SecurityScheme securityScheme = OASFactory.createSecurityScheme(); | ||
securityScheme.setType(SecurityScheme.Type.HTTP); | ||
securityScheme.setScheme(jwtSecuritySchemeValue); | ||
securityScheme.setBearerFormat(jwtBearerFormat); | ||
return securityScheme; | ||
} | ||
} |
Oops, something went wrong.