BAEL-797 Disabling csrf on the logout link as it was creating problems with the csrf token not being updated correctly.
This commit is contained in:
+1
-2
@@ -15,7 +15,7 @@
|
||||
</form>
|
||||
</ng-template>
|
||||
<ng-template #loginMessage>
|
||||
<button type="button" class="btn btn-link">Logout</button>
|
||||
<button type="button" class="btn btn-link" (click)="onLogout()">Logout</button>
|
||||
</ng-template>
|
||||
<div *ngIf="loginFailed">
|
||||
<div class="alert alert-warning">Login Failed</div>
|
||||
@@ -29,5 +29,4 @@
|
||||
<h1>Book Rater App</h1>
|
||||
<p class="lead">Keep track of all the latest books and their ratings.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
+30
-5
@@ -1,21 +1,23 @@
|
||||
import {Component, OnInit} from "@angular/core";
|
||||
import {NgForm} from "@angular/forms";
|
||||
import {RequestOptions, Http, Response, Headers} from "@angular/http";
|
||||
import "rxjs/Rx";
|
||||
import {Component} from "@angular/core";
|
||||
import {Principal} from "./principal";
|
||||
import {Response, RequestOptions, Headers, Http} from "@angular/http";
|
||||
import {Observable} from "rxjs";
|
||||
import {NgForm} from "@angular/forms";
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.css']
|
||||
})
|
||||
export class AppComponent implements OnInit{
|
||||
export class AppComponent {
|
||||
credentials = {
|
||||
username: '',
|
||||
password: ''
|
||||
};
|
||||
|
||||
private username: String = '';
|
||||
private password: String = '';
|
||||
|
||||
principal: Principal = new Principal(false, []);
|
||||
|
||||
loginFailed: boolean = false;
|
||||
@@ -29,6 +31,9 @@ export class AppComponent implements OnInit{
|
||||
onLogin(form: NgForm) {
|
||||
this.loginFailed = false;
|
||||
let headers = new Headers({'Content-Type': 'application/json'});
|
||||
this.username = form.value.username;
|
||||
this.password = form.value.password;
|
||||
|
||||
headers.append('Authorization','Basic ' + btoa(form.value.username + ':' + form.value.password));
|
||||
headers.append('X-Requested-With','XMLHttpRequest');
|
||||
let options = new RequestOptions({headers: headers});
|
||||
@@ -47,4 +52,24 @@ export class AppComponent implements OnInit{
|
||||
this.principal = principal;
|
||||
});
|
||||
}
|
||||
|
||||
onLogout() {
|
||||
let headers = new Headers({'Content-Type': 'application/json'});
|
||||
headers.append('Authorization','Basic ' + btoa(this.username + ':' + this.password));
|
||||
headers.append('X-Requested-With','XMLHttpRequest');
|
||||
let options = new RequestOptions({headers: headers});
|
||||
this.http.post("/logout", '', options)
|
||||
.catch((error: Response) => {
|
||||
console.log(error);
|
||||
return Observable.throw(error);
|
||||
})
|
||||
.subscribe((response: Response) => {
|
||||
if (response.status === 204) {
|
||||
this.loginFailed = false;
|
||||
this.credentials.username = '';
|
||||
this.credentials.password = '';
|
||||
this.principal = new Principal(false, []);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -35,11 +35,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/eureka/**").hasRole("ADMIN")
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.logout().permitAll()
|
||||
.logoutSuccessUrl("/").permitAll()
|
||||
.logout()
|
||||
.and()
|
||||
.addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class)
|
||||
.csrf().csrfTokenRepository(csrfTokenRepository());
|
||||
.csrf().csrfTokenRepository(csrfTokenRepository()).ignoringAntMatchers("/logout");
|
||||
}
|
||||
|
||||
private CsrfTokenRepository csrfTokenRepository() {
|
||||
|
||||
+1
File diff suppressed because one or more lines are too long
+52
-31
@@ -1,6 +1,6 @@
|
||||
webpackJsonp([1,4],{
|
||||
|
||||
/***/ 197:
|
||||
/***/ 196:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
function webpackEmptyContext(req) {
|
||||
@@ -9,20 +9,20 @@ function webpackEmptyContext(req) {
|
||||
webpackEmptyContext.keys = function() { return []; };
|
||||
webpackEmptyContext.resolve = webpackEmptyContext;
|
||||
module.exports = webpackEmptyContext;
|
||||
webpackEmptyContext.id = 197;
|
||||
webpackEmptyContext.id = 196;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 198:
|
||||
/***/ 197:
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(1);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_platform_browser_dynamic__ = __webpack_require__(203);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__app_app_module__ = __webpack_require__(209);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__environments_environment__ = __webpack_require__(211);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_platform_browser_dynamic__ = __webpack_require__(202);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__app_app_module__ = __webpack_require__(208);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__environments_environment__ = __webpack_require__(210);
|
||||
|
||||
|
||||
|
||||
@@ -35,17 +35,15 @@ __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__angular_platform_browser_dyna
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 208:
|
||||
/***/ 207:
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(1);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http__ = __webpack_require__(102);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_Rx__ = __webpack_require__(161);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_Rx___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_rxjs_Rx__);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__principal__ = __webpack_require__(210);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs__ = __webpack_require__(161);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_rxjs__);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__principal__ = __webpack_require__(209);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__angular_http__ = __webpack_require__(102);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_rxjs__ = __webpack_require__(269);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_rxjs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_rxjs__);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AppComponent; });
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
@@ -60,7 +58,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
|
||||
|
||||
|
||||
|
||||
var AppComponent = (function () {
|
||||
function AppComponent(http) {
|
||||
this.http = http;
|
||||
@@ -68,7 +65,9 @@ var AppComponent = (function () {
|
||||
username: '',
|
||||
password: ''
|
||||
};
|
||||
this.principal = new __WEBPACK_IMPORTED_MODULE_3__principal__["a" /* Principal */](false, []);
|
||||
this.username = '';
|
||||
this.password = '';
|
||||
this.principal = new __WEBPACK_IMPORTED_MODULE_1__principal__["a" /* Principal */](false, []);
|
||||
this.loginFailed = false;
|
||||
}
|
||||
AppComponent.prototype.ngOnInit = function () {
|
||||
@@ -76,10 +75,12 @@ var AppComponent = (function () {
|
||||
AppComponent.prototype.onLogin = function (form) {
|
||||
var _this = this;
|
||||
this.loginFailed = false;
|
||||
var headers = new __WEBPACK_IMPORTED_MODULE_1__angular_http__["b" /* Headers */]({ 'Content-Type': 'application/json' });
|
||||
var headers = new __WEBPACK_IMPORTED_MODULE_2__angular_http__["b" /* Headers */]({ 'Content-Type': 'application/json' });
|
||||
this.username = form.value.username;
|
||||
this.password = form.value.password;
|
||||
headers.append('Authorization', 'Basic ' + btoa(form.value.username + ':' + form.value.password));
|
||||
headers.append('X-Requested-With', 'XMLHttpRequest');
|
||||
var options = new __WEBPACK_IMPORTED_MODULE_1__angular_http__["c" /* RequestOptions */]({ headers: headers });
|
||||
var options = new __WEBPACK_IMPORTED_MODULE_2__angular_http__["c" /* RequestOptions */]({ headers: headers });
|
||||
this.http.get("/me", options)
|
||||
.map(function (response) { return response.json(); })
|
||||
.catch(function (error) {
|
||||
@@ -87,23 +88,43 @@ var AppComponent = (function () {
|
||||
_this.loginFailed = true;
|
||||
}
|
||||
console.log(error);
|
||||
return __WEBPACK_IMPORTED_MODULE_4_rxjs__["Observable"].throw(error);
|
||||
return __WEBPACK_IMPORTED_MODULE_3_rxjs__["Observable"].throw(error);
|
||||
})
|
||||
.map(function (data) { return new __WEBPACK_IMPORTED_MODULE_3__principal__["a" /* Principal */](data.authenticated, data.authorities); })
|
||||
.map(function (data) { return new __WEBPACK_IMPORTED_MODULE_1__principal__["a" /* Principal */](data.authenticated, data.authorities); })
|
||||
.subscribe(function (principal) {
|
||||
console.log(principal);
|
||||
_this.principal = principal;
|
||||
});
|
||||
};
|
||||
AppComponent.prototype.onLogout = function () {
|
||||
var _this = this;
|
||||
var headers = new __WEBPACK_IMPORTED_MODULE_2__angular_http__["b" /* Headers */]({ 'Content-Type': 'application/json' });
|
||||
headers.append('Authorization', 'Basic ' + btoa(this.username + ':' + this.password));
|
||||
headers.append('X-Requested-With', 'XMLHttpRequest');
|
||||
var options = new __WEBPACK_IMPORTED_MODULE_2__angular_http__["c" /* RequestOptions */]({ headers: headers });
|
||||
this.http.post("/logout", '', options)
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return __WEBPACK_IMPORTED_MODULE_3_rxjs__["Observable"].throw(error);
|
||||
})
|
||||
.subscribe(function (response) {
|
||||
if (response.status === 204) {
|
||||
_this.loginFailed = false;
|
||||
_this.credentials.username = '';
|
||||
_this.credentials.password = '';
|
||||
_this.principal = new __WEBPACK_IMPORTED_MODULE_1__principal__["a" /* Principal */](false, []);
|
||||
}
|
||||
});
|
||||
};
|
||||
return AppComponent;
|
||||
}());
|
||||
AppComponent = __decorate([
|
||||
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* Component */])({
|
||||
selector: 'app-root',
|
||||
template: __webpack_require__(268),
|
||||
styles: [__webpack_require__(266)]
|
||||
template: __webpack_require__(267),
|
||||
styles: [__webpack_require__(265)]
|
||||
}),
|
||||
__metadata("design:paramtypes", [typeof (_a = typeof __WEBPACK_IMPORTED_MODULE_1__angular_http__["d" /* Http */] !== "undefined" && __WEBPACK_IMPORTED_MODULE_1__angular_http__["d" /* Http */]) === "function" && _a || Object])
|
||||
__metadata("design:paramtypes", [typeof (_a = typeof __WEBPACK_IMPORTED_MODULE_2__angular_http__["d" /* Http */] !== "undefined" && __WEBPACK_IMPORTED_MODULE_2__angular_http__["d" /* Http */]) === "function" && _a || Object])
|
||||
], AppComponent);
|
||||
|
||||
var _a;
|
||||
@@ -111,7 +132,7 @@ var _a;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 209:
|
||||
/***/ 208:
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
@@ -119,8 +140,8 @@ var _a;
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_core__ = __webpack_require__(1);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__angular_forms__ = __webpack_require__(23);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__angular_http__ = __webpack_require__(102);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__app_component__ = __webpack_require__(208);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__ng_bootstrap_ng_bootstrap__ = __webpack_require__(206);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__app_component__ = __webpack_require__(207);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__ng_bootstrap_ng_bootstrap__ = __webpack_require__(205);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AppModule; });
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
@@ -159,7 +180,7 @@ AppModule = __decorate([
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 210:
|
||||
/***/ 209:
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
@@ -192,7 +213,7 @@ var Authority = (function () {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 211:
|
||||
/***/ 210:
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
@@ -209,7 +230,7 @@ var environment = {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 266:
|
||||
/***/ 265:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
exports = module.exports = __webpack_require__(50)();
|
||||
@@ -227,17 +248,17 @@ module.exports = module.exports.toString();
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 268:
|
||||
/***/ 267:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = "<nav class=\"navbar navbar-toggleable-md navbar-inverse fixed-top bg-inverse\">\n <button class=\"navbar-toggler navbar-toggler-right\" type=\"button\" data-toggle=\"collapse\" data-target=\"#navbarCollapse\" aria-controls=\"navbarCollapse\" aria-expanded=\"false\" aria-label=\"Toggle navigation\">\n <span class=\"navbar-toggler-icon\"></span>\n </button>\n <a class=\"navbar-brand\" href=\"#\">Book Rater</a>\n <div class=\"collapse navbar-collapse\" id=\"navbarCollapse\">\n <ul class=\"navbar-nav mr-auto\">\n </ul>\n <div *ngIf=\"!principal.authenticated; then loginForm else loginMessage\"></div>\n <ng-template #loginForm>\n <form (ngSubmit)=\"onLogin(f)\" class=\"form-inline mt-2 mt-md-0\" #f=\"ngForm\">\n <input name=\"username\" [(ngModel)]=\"credentials.username\" required class=\"form-control mr-sm-2\" type=\"text\" placeholder=\"Username\">\n <input name=\"password\" [(ngModel)]=\"credentials.password\" required class=\"form-control mr-sm-2\" type=\"password\" placeholder=\"Password\">\n <button class=\"btn btn-outline-success my-2 my-sm-0\" type=\"submit\" [disabled]=\"!f.valid\">Login</button>\n </form>\n </ng-template>\n <ng-template #loginMessage>\n <button type=\"button\" class=\"btn btn-link\">Logout</button>\n </ng-template>\n <div *ngIf=\"loginFailed\">\n <div class=\"alert alert-warning\">Login Failed</div>\n </div>\n\n </div>\n</nav>\n\n<div class=\"container\">\n <div class=\"jumbotron\">\n <h1>Book Rater App</h1>\n <p class=\"lead\">Keep track of all the latest books and their ratings.</p>\n </div>\n\n</div>\n"
|
||||
module.exports = "<nav class=\"navbar navbar-toggleable-md navbar-inverse fixed-top bg-inverse\">\n <button class=\"navbar-toggler navbar-toggler-right\" type=\"button\" data-toggle=\"collapse\" data-target=\"#navbarCollapse\" aria-controls=\"navbarCollapse\" aria-expanded=\"false\" aria-label=\"Toggle navigation\">\n <span class=\"navbar-toggler-icon\"></span>\n </button>\n <a class=\"navbar-brand\" href=\"#\">Book Rater</a>\n <div class=\"collapse navbar-collapse\" id=\"navbarCollapse\">\n <ul class=\"navbar-nav mr-auto\">\n </ul>\n <div *ngIf=\"!principal.authenticated; then loginForm else loginMessage\"></div>\n <ng-template #loginForm>\n <form (ngSubmit)=\"onLogin(f)\" class=\"form-inline mt-2 mt-md-0\" #f=\"ngForm\">\n <input name=\"username\" [(ngModel)]=\"credentials.username\" required class=\"form-control mr-sm-2\" type=\"text\" placeholder=\"Username\">\n <input name=\"password\" [(ngModel)]=\"credentials.password\" required class=\"form-control mr-sm-2\" type=\"password\" placeholder=\"Password\">\n <button class=\"btn btn-outline-success my-2 my-sm-0\" type=\"submit\" [disabled]=\"!f.valid\">Login</button>\n </form>\n </ng-template>\n <ng-template #loginMessage>\n <button type=\"button\" class=\"btn btn-link\" (click)=\"onLogout()\">Logout</button>\n </ng-template>\n <div *ngIf=\"loginFailed\">\n <div class=\"alert alert-warning\">Login Failed</div>\n </div>\n\n </div>\n</nav>\n\n<div class=\"container\">\n <div class=\"jumbotron\">\n <h1>Book Rater App</h1>\n <p class=\"lead\">Keep track of all the latest books and their ratings.</p>\n </div>\n</div>\n"
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 537:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(198);
|
||||
module.exports = __webpack_require__(197);
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
+1
File diff suppressed because one or more lines are too long
+131
-131
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+11
-11
@@ -1,6 +1,6 @@
|
||||
webpackJsonp([2,4],{
|
||||
|
||||
/***/ 196:
|
||||
/***/ 195:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
/*
|
||||
@@ -253,16 +253,16 @@ function updateLink(linkElement, obj) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 200:
|
||||
/***/ 199:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
// style-loader: Adds some css to the DOM by adding a <style> tag
|
||||
|
||||
// load the styles
|
||||
var content = __webpack_require__(264);
|
||||
var content = __webpack_require__(263);
|
||||
if(typeof content === 'string') content = [[module.i, content, '']];
|
||||
// add the styles to the DOM
|
||||
var update = __webpack_require__(196)(content, {});
|
||||
var update = __webpack_require__(195)(content, {});
|
||||
if(content.locals) module.exports = content.locals;
|
||||
// Hot Module Replacement
|
||||
if(false) {
|
||||
@@ -280,16 +280,16 @@ if(false) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 201:
|
||||
/***/ 200:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
// style-loader: Adds some css to the DOM by adding a <style> tag
|
||||
|
||||
// load the styles
|
||||
var content = __webpack_require__(265);
|
||||
var content = __webpack_require__(264);
|
||||
if(typeof content === 'string') content = [[module.i, content, '']];
|
||||
// add the styles to the DOM
|
||||
var update = __webpack_require__(196)(content, {});
|
||||
var update = __webpack_require__(195)(content, {});
|
||||
if(content.locals) module.exports = content.locals;
|
||||
// Hot Module Replacement
|
||||
if(false) {
|
||||
@@ -307,7 +307,7 @@ if(false) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 264:
|
||||
/***/ 263:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
exports = module.exports = __webpack_require__(50)();
|
||||
@@ -322,7 +322,7 @@ exports.push([module.i, "/*!\n * Bootstrap v4.0.0-alpha.6 (https://getbootstrap.
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 265:
|
||||
/***/ 264:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
exports = module.exports = __webpack_require__(50)();
|
||||
@@ -397,8 +397,8 @@ module.exports = function() {
|
||||
/***/ 539:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
__webpack_require__(201);
|
||||
module.exports = __webpack_require__(200);
|
||||
__webpack_require__(200);
|
||||
module.exports = __webpack_require__(199);
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
+1
File diff suppressed because one or more lines are too long
+348
-348
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user