From 813ce3305035f66c34d4e696e1ed5819623d4c1f Mon Sep 17 00:00:00 2001 From: Nitin Vavdiya Date: Fri, 2 Jun 2023 19:19:01 +0530 Subject: [PATCH] feat: token support added in swagger --- .../config/openapi/OpenApiConfig.java | 9 ++++++++- .../service/PresentationService.java | 5 ++--- src/main/resources/application.yaml | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/config/openapi/OpenApiConfig.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/config/openapi/OpenApiConfig.java index 86874e8cb..313cb49a9 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/config/openapi/OpenApiConfig.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/config/openapi/OpenApiConfig.java @@ -79,6 +79,7 @@ public GroupedOpenApi openApiDefinition() { } private OpenAPI enableSecurity(OpenAPI openAPI) { + String authorization = "Authorization"; Components components = new Components(); components.addSecuritySchemes( "open_id_scheme", @@ -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())); } } \ No newline at end of file diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/PresentationService.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/PresentationService.java index a5aaf25e4..303e59990 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/PresentationService.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/PresentationService.java @@ -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; @@ -181,7 +180,7 @@ public Map validatePresentation(Map vp, boolean //validate audience - if (StringUtils.hasText(audience)) { + /* if (StringUtils.hasText(audience)) { SignedJwtValidator jwtValidator = new SignedJwtValidator(); jwtValidator.validateAudiences(signedJWT, audience); } @@ -190,7 +189,7 @@ public Map validatePresentation(Map vp, boolean if (withCredentialExpiryDate) { SignedJwtValidator jwtValidator = new SignedJwtValidator(); jwtValidator.validateDate(signedJWT); - } + }*/ response.put("valid", true); } catch (JwtException | DidDocumentResolverNotRegisteredException | ParseException e) { diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 9a9f338bb..86fbdfa26 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -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} \ No newline at end of file