Skip to content

Commit

Permalink
feat(server): log login and logout actions (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarimGl authored Mar 4, 2024
1 parent a6ce44a commit 27bc48d
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 20 deletions.
2 changes: 1 addition & 1 deletion chutney/action-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>action-impl</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/action-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>action-spi</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/chutney-junit/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-junit-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>chutney-junit-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/chutney-junit/engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-junit-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>chutney-junit-engine</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/chutney-junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>chutney-junit-parent</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>engine</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/environment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>chutney-parent</artifactId>
<groupId>com.chutneytesting</groupId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion chutney/glacio-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>glacio-adapter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/jira/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>chutney-parent</artifactId>
<groupId>com.chutneytesting</groupId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion chutney/packaging/local-api-unsecure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>packaging</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>local-api-unsecure</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/packaging/local-dev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>packaging</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>local-dev</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/packaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>
<artifactId>packaging</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion chutney/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Chutney</name>
Expand Down
2 changes: 1 addition & 1 deletion chutney/server-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>chutney-parent</artifactId>
<groupId>com.chutneytesting</groupId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>server-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.chutneytesting.security.domain.Authorizations;
import com.chutneytesting.security.infra.handlers.Http401FailureHandler;
import com.chutneytesting.security.infra.handlers.HttpEmptyLogoutSuccessHandler;
import com.chutneytesting.security.infra.handlers.HttpLoginSuccessHandler;
import com.chutneytesting.server.core.domain.security.Authorization;
import com.chutneytesting.server.core.domain.security.User;
import java.util.ArrayList;
Expand Down Expand Up @@ -87,7 +88,7 @@ protected void configureBaseHttpSecurity(final HttpSecurity http) throws Excepti
.requiresChannel(channelRequestMatcherRegistry -> channelRequestMatcherRegistry.anyRequest().requiresSecure())
.formLogin(httpSecurityFormLoginConfigurer -> httpSecurityFormLoginConfigurer
.loginProcessingUrl(LOGIN_URL)
.successForwardUrl(UserController.BASE_URL)
.successHandler(new HttpLoginSuccessHandler())
.failureHandler(new Http401FailureHandler()))
.logout(httpSecurityLogoutConfigurer -> httpSecurityLogoutConfigurer
.logoutUrl(LOGOUT_URL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

public class HttpEmptyLogoutSuccessHandler implements LogoutSuccessHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HttpEmptyLogoutSuccessHandler.class);

@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
response.setStatus(HttpServletResponse.SC_OK);
response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
response.getOutputStream().print("");
if (authentication != null) {
LOGGER.info("User {} logged out", authentication.getName());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2017-2023 Enedis
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.chutneytesting.security.infra.handlers;

import com.chutneytesting.security.api.UserController;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

public class HttpLoginSuccessHandler implements AuthenticationSuccessHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HttpLoginSuccessHandler.class);


@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
LOGGER.info("User {} logged in", authentication.getName());
request.getRequestDispatcher(UserController.BASE_URL).forward(request, response);
}
}
2 changes: 1 addition & 1 deletion chutney/tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>tools</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion chutney/ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.chutneytesting</groupId>
<artifactId>chutney-parent</artifactId>
<version>2.7.1-RC</version>
<version>2.7.1-SNAPSHOT</version>
</parent>

<artifactId>ui</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion idea-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ org.gradle.jvmargs=-Xmx2048M

pluginGroup = com.chutneytesting.idea
pluginName = chutney-idea-plugin
chutneyVersion = 2.7.1-RC
chutneyVersion = 2.7.1-SNAPSHOT

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand Down
2 changes: 1 addition & 1 deletion kotlin-dsl/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chutneyVersion = 2.7.1-RC
chutneyVersion = 2.7.1-SNAPSHOT

0 comments on commit 27bc48d

Please sign in to comment.