Commit 6eff7914 by Johannes Edmeier

Add handling for 401 on XHR responses.

parent 4c56589a
......@@ -46,6 +46,20 @@
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -31,6 +31,7 @@ import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
@Configuration
@EnableAutoConfiguration
......@@ -56,16 +57,19 @@ public class SpringBootAdminApplication {
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
http.authorizeRequests()
.antMatchers("/assets/**").permitAll()
.antMatchers("/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").and()
.formLogin().loginPage("/login").successHandler(successHandler).and()
.logout().and()
.httpBasic().and()
.csrf().disable();
// @formatter:on
// @formatter:on
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -51,7 +51,7 @@
"css-hot-loader": "^1.3.5",
"css-loader": "^0.28.9",
"css-mqpacker": "^6.0.1",
"eslint": "^4.15.0",
"eslint": "^4.16.0",
"eslint-plugin-html": "^4.0.1",
"eslint-plugin-vue-libs": "^2.1.0",
"extract-text-webpack-plugin": "^3.0.2",
......@@ -60,7 +60,7 @@
"html-loader": "^0.5.5",
"html-webpack-plugin": "^2.30.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^22.1.3",
"jest": "^22.1.4",
"jest-vue": "^0.8.2",
"lodash-webpack-plugin": "^0.11.4",
"node-sass": "^4.7.2",
......@@ -73,8 +73,7 @@
"vue-svg-loader": "^0.4.0",
"vue-template-compiler": "^2.5.13",
"webpack": "^3.10.0",
"webpack-bundle-analyzer": "^2.9.2",
"webpack-dev-server": "^2.11.0"
"webpack-bundle-analyzer": "^2.9.2"
},
"browserslist": [
"> 2%",
......
......@@ -14,6 +14,7 @@
* limitations under the License.
*/
import axios from 'axios';
import moment from 'moment';
import Vue from 'vue';
import VueRouter from 'vue-router';
......@@ -38,6 +39,17 @@ const router = new VueRouter({
});
Notifications.requestPermissions();
axios.interceptors.request.use(config => {
config.headers['X-Requested-With'] = 'XMLHttpRequest';
return config;
});
axios.interceptors.response.use(response => response, error => {
if (401 === error.response.status) {
window.location = `login?redirectTo=${encodeURIComponent(window.location.href)}`;
}
return Promise.reject(error);
});
const store = new Store();
......
......@@ -33,7 +33,7 @@
<div class="column is-4 is-offset-4">
<div class="box">
<h1 class="title">Spring Boot Admin</h1>
<form method="post" action="login">
<form method="post">
<div class="field">
<p class="is-medium has-text-danger" th:unless="${param.error == null}">
Invalid username or password!
......
......@@ -56,7 +56,7 @@
<font-awesome-icon size="lg" :icon="['fab', 'gitter']"></font-awesome-icon>&nbsp;Gitter</a>
</div>
</div>
<h1 class="title is-5">Trademarks and License</h1>
<h1 class="title is-5">Trademarks and Licenses</h1>
<div class="content">
<p>
The source code of Spring Boot Admin is licensed under <a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment