diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/LogoutController.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/LogoutController.java new file mode 100644 index 0000000000000000000000000000000000000000..dbe6419d8b8400775fc6b7a17df7128473277d80 --- /dev/null +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/LogoutController.java @@ -0,0 +1,44 @@ +/* + ******************************************************************************* + * Copyright (c) 2019 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + ******************************************************************************* + */ +package org.eclipse.openk.gridfailureinformation.controller; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import lombok.extern.log4j.Log4j2; +import org.eclipse.openk.gridfailureinformation.service.LogoutService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Log4j2 +@RestController +@RequestMapping("/logout") +public class LogoutController { + + @Autowired + private LogoutService logoutService; + + @ApiOperation(value = "Logout vom Auth-und-Auth-Modul") + @ApiResponses(value = {@ApiResponse(code = 204, message = "Erfolgreich durchgeführt")}) + @GetMapping + public ResponseEntity logout() { + logoutService.logout(); + return ResponseEntity.ok().build(); + } + +} diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/LogoutService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/LogoutService.java new file mode 100644 index 0000000000000000000000000000000000000000..e6c8dcb1e4af5eb8c747bfa61cb0f49dfeee41d4 --- /dev/null +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/LogoutService.java @@ -0,0 +1,31 @@ +/* + ******************************************************************************* + * Copyright (c) 2019 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + ******************************************************************************* +*/ +package org.eclipse.openk.gridfailureinformation.service; + +import org.eclipse.openk.gridfailureinformation.api.AuthNAuthApi; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Service; + +@Service +public class LogoutService { + @Autowired + AuthNAuthApi authNAuthApi; + + public void logout() { + String bearerToken = (String) SecurityContextHolder.getContext().getAuthentication().getDetails(); + authNAuthApi.logout(bearerToken); + } +} diff --git a/gfsBackendService/src/main/resources/application_localdev.yml b/gfsBackendService/src/main/resources/application_localdev.yml index 53edb4377bb15acece4b703c65180579ed36df46..e6e8dc74cfebe84b94bf25adebb4cc6866a626fd 100644 --- a/gfsBackendService/src/main/resources/application_localdev.yml +++ b/gfsBackendService/src/main/resources/application_localdev.yml @@ -30,7 +30,7 @@ gridFailureInformation: jwt: tokenHeader: Authorization - useStaticJwt: true + useStaticJwt: false staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI5MGI0NGFkOC1iYjlmLTQ1MzktYTQwYy0yYjQyZTNkNjNiOGEiLCJleHAiOjE1Nzg2NTU3OTUsIm5iZiI6MCwiaWF0IjoxNTc4NjU1NDk1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiODYyNjY5NmYtZjFhMi00ZGI1LTkyZWYtZT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