Skip to content

Commit

Permalink
feat: token support added in swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
nitin-vavdiya committed Jun 2, 2023
1 parent e4c2ff0 commit 813ce33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public GroupedOpenApi openApiDefinition() {
}

private OpenAPI enableSecurity(OpenAPI openAPI) {
String authorization = "Authorization";
Components components = new Components();
components.addSecuritySchemes(
"open_id_scheme",
Expand All @@ -93,7 +94,13 @@ private OpenAPI enableSecurity(OpenAPI openAPI) {
)
)
);

components.addSecuritySchemes(authorization,
new SecurityScheme().name(authorization)
.type(SecurityScheme.Type.HTTP).scheme("Bearer"));
return openAPI.components(components)
.addSecurityItem(new SecurityRequirement().addList("open_id_scheme", Collections.emptyList()));
.addSecurityItem(new SecurityRequirement()
.addList(authorization, Collections.emptyList())
.addList("open_id_scheme", Collections.emptyList()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.eclipse.tractusx.ssi.lib.exception.DidDocumentResolverNotRegisteredException;
import org.eclipse.tractusx.ssi.lib.exception.JwtException;
import org.eclipse.tractusx.ssi.lib.jwt.SignedJwtFactory;
import org.eclipse.tractusx.ssi.lib.jwt.SignedJwtValidator;
import org.eclipse.tractusx.ssi.lib.jwt.SignedJwtVerifier;
import org.eclipse.tractusx.ssi.lib.model.did.Did;
import org.eclipse.tractusx.ssi.lib.model.did.DidParser;
Expand Down Expand Up @@ -181,7 +180,7 @@ public Map<String, Object> validatePresentation(Map<String, Object> vp, boolean


//validate audience
if (StringUtils.hasText(audience)) {
/* if (StringUtils.hasText(audience)) {
SignedJwtValidator jwtValidator = new SignedJwtValidator();
jwtValidator.validateAudiences(signedJWT, audience);
}
Expand All @@ -190,7 +189,7 @@ public Map<String, Object> validatePresentation(Map<String, Object> vp, boolean
if (withCredentialExpiryDate) {
SignedJwtValidator jwtValidator = new SignedJwtValidator();
jwtValidator.validateDate(signedJWT);
}
}*/

response.put("valid", true);
} catch (JwtException | DidDocumentResolverNotRegisteredException | ParseException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ miw:
enabled: true
realm: ${KEYCLOAK_REALM:miw_test}
clientId: ${KEYCLOAK_CLIENT_ID:miw_private_client}
auth-server-url: ${AUTH_SERVER_URL:https://localhost:8080}
auth-server-url: ${AUTH_SERVER_URL:http://localhost:8081}
auth-url: ${miw.security.auth-server-url}/realms/${miw.security.realm}/protocol/openid-connect/auth
token-url: ${miw.security.auth-server-url}/realms/${miw.security.realm}/protocol/openid-connect/token
refresh-token-url: ${miw.security.token-url}

0 comments on commit 813ce33

Please sign in to comment.