Commit 6eff7914 by Johannes Edmeier

Add handling for 401 on XHR responses.

parent 4c56589a
...@@ -46,6 +46,20 @@ ...@@ -46,6 +46,20 @@
<groupId>de.codecentric</groupId> <groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId> <artifactId>spring-boot-admin-starter-client</artifactId>
</dependency> </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 --> <!-- Test -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -31,6 +31,7 @@ import org.springframework.context.annotation.Profile; ...@@ -31,6 +31,7 @@ import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
@Configuration @Configuration
@EnableAutoConfiguration @EnableAutoConfiguration
...@@ -56,16 +57,19 @@ public class SpringBootAdminApplication { ...@@ -56,16 +57,19 @@ public class SpringBootAdminApplication {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
http.authorizeRequests() http.authorizeRequests()
.antMatchers("/assets/**").permitAll() .antMatchers("/assets/**").permitAll()
.antMatchers("/login").permitAll() .antMatchers("/login").permitAll()
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()
.formLogin().loginPage("/login").and() .formLogin().loginPage("/login").successHandler(successHandler).and()
.logout().and() .logout().and()
.httpBasic().and() .httpBasic().and()
.csrf().disable(); .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 @@ ...@@ -51,7 +51,7 @@
"css-hot-loader": "^1.3.5", "css-hot-loader": "^1.3.5",
"css-loader": "^0.28.9", "css-loader": "^0.28.9",
"css-mqpacker": "^6.0.1", "css-mqpacker": "^6.0.1",
"eslint": "^4.15.0", "eslint": "^4.16.0",
"eslint-plugin-html": "^4.0.1", "eslint-plugin-html": "^4.0.1",
"eslint-plugin-vue-libs": "^2.1.0", "eslint-plugin-vue-libs": "^2.1.0",
"extract-text-webpack-plugin": "^3.0.2", "extract-text-webpack-plugin": "^3.0.2",
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
"html-loader": "^0.5.5", "html-loader": "^0.5.5",
"html-webpack-plugin": "^2.30.0", "html-webpack-plugin": "^2.30.0",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jest": "^22.1.3", "jest": "^22.1.4",
"jest-vue": "^0.8.2", "jest-vue": "^0.8.2",
"lodash-webpack-plugin": "^0.11.4", "lodash-webpack-plugin": "^0.11.4",
"node-sass": "^4.7.2", "node-sass": "^4.7.2",
...@@ -73,8 +73,7 @@ ...@@ -73,8 +73,7 @@
"vue-svg-loader": "^0.4.0", "vue-svg-loader": "^0.4.0",
"vue-template-compiler": "^2.5.13", "vue-template-compiler": "^2.5.13",
"webpack": "^3.10.0", "webpack": "^3.10.0",
"webpack-bundle-analyzer": "^2.9.2", "webpack-bundle-analyzer": "^2.9.2"
"webpack-dev-server": "^2.11.0"
}, },
"browserslist": [ "browserslist": [
"> 2%", "> 2%",
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import axios from 'axios';
import moment from 'moment'; import moment from 'moment';
import Vue from 'vue'; import Vue from 'vue';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
...@@ -38,6 +39,17 @@ const router = new VueRouter({ ...@@ -38,6 +39,17 @@ const router = new VueRouter({
}); });
Notifications.requestPermissions(); 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(); const store = new Store();
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<div class="column is-4 is-offset-4"> <div class="column is-4 is-offset-4">
<div class="box"> <div class="box">
<h1 class="title">Spring Boot Admin</h1> <h1 class="title">Spring Boot Admin</h1>
<form method="post" action="login"> <form method="post">
<div class="field"> <div class="field">
<p class="is-medium has-text-danger" th:unless="${param.error == null}"> <p class="is-medium has-text-danger" th:unless="${param.error == null}">
Invalid username or password! Invalid username or password!
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<font-awesome-icon size="lg" :icon="['fab', 'gitter']"></font-awesome-icon>&nbsp;Gitter</a> <font-awesome-icon size="lg" :icon="['fab', 'gitter']"></font-awesome-icon>&nbsp;Gitter</a>
</div> </div>
</div> </div>
<h1 class="title is-5">Trademarks and License</h1> <h1 class="title is-5">Trademarks and Licenses</h1>
<div class="content"> <div class="content">
<p> <p>
The source code of Spring Boot Admin is licensed under <a 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