diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/SecurityConfig.java b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/SecurityConfig.java index 265200d96e..204b4a0c77 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/SecurityConfig.java +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/SecurityConfig.java @@ -1,15 +1,11 @@ package com.baeldung.spring.cloud.bootstrap.gateway; -import com.baeldung.spring.cloud.bootstrap.gateway.filter.CsrfHeaderFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.csrf.CsrfFilter; -import org.springframework.security.web.csrf.CsrfTokenRepository; -import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository; @EnableWebSecurity @Configuration @@ -27,8 +23,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { protected void configure(HttpSecurity http) throws Exception { http .formLogin() - .loginPage("/login.html") - .loginProcessingUrl("/login") .defaultSuccessUrl("/home/index.html", true) .and() .authorizeRequests() @@ -39,13 +33,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .and() .logout() .and() - .addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class) - .csrf().csrfTokenRepository(csrfTokenRepository()); - } - - private CsrfTokenRepository csrfTokenRepository() { - HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository(); - repository.setHeaderName("X-XSRF-TOKEN"); - return repository; + .csrf().disable(); } } diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/filter/CsrfHeaderFilter.java b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/filter/CsrfHeaderFilter.java deleted file mode 100644 index c9c10db3fc..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/filter/CsrfHeaderFilter.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.spring.cloud.bootstrap.gateway.filter; - -import org.springframework.security.web.csrf.CsrfToken; -import org.springframework.web.filter.OncePerRequestFilter; -import org.springframework.web.util.WebUtils; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -public class CsrfHeaderFilter extends OncePerRequestFilter { - @Override - protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException { - CsrfToken csrfToken = (CsrfToken) httpServletRequest.getAttribute(CsrfToken.class.getName()); - if (csrfToken != null) { - Cookie cookie = WebUtils.getCookie(httpServletRequest, "XSRF-TOKEN"); - String token = csrfToken.getToken(); - if (cookie == null || token != null && !token.equals(cookie.getValue())) { - cookie = new Cookie("XSRF-TOKEN", token); - cookie.setPath("/"); - httpServletResponse.addCookie(cookie); - } - } - filterChain.doFilter(httpServletRequest, httpServletResponse); - } -} diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/home/main.bundle.js.map b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/home/main.bundle.js.map index 2611f5ecf5..676177396e 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/home/main.bundle.js.map +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/home/main.bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///./src/app/app.component.css","webpack:///./src/app/book/book-detail/book-detail.component.css","webpack:///./src/app/book/book-list/book-list.component.css","webpack:///./src/app/rating/rating.component.css","webpack:///./src/app/app.component.html","webpack:///./src/app/book/book-detail/book-detail.component.html","webpack:///./src/app/book/book-list/book-list.component.html","webpack:///./src/app/rating/rating.component.html","webpack:///./src/app/http.service.ts","webpack:///./src/app/principal.ts","webpack:///./src/app/book.ts","webpack:///./src async","webpack:///./src/main.ts","webpack:///./src/app/app.component.ts","webpack:///./src/app/app.module.ts","webpack:///./src/app/book/book-detail/book-detail.component.ts","webpack:///./src/app/book/book-list/book-list.component.ts","webpack:///./src/app/click-stop-propagation.directive.ts","webpack:///./src/app/rating.ts","webpack:///./src/app/rating/rating.component.ts","webpack:///./src/environments/environment.ts"],"names":[],"mappings":";;;;;AAAA;AACA;;;AAGA;AACA,wCAAyC,kBAAkB,KAAK;;AAEhE;;;AAGA;AACA,2C;;;;;;;ACXA;AACA;;;AAGA;AACA;;AAEA;;;AAGA;AACA,2C;;;;;;;ACXA;AACA;;;AAGA;AACA,wCAAyC,kBAAkB,KAAK;;AAEhE;;;AAGA;AACA,2C;;;;;;;ACXA;AACA;;;AAGA;AACA,uCAAwC,sBAAsB,KAAK,uBAAuB,yBAAyB,KAAK,mBAAmB,yBAAyB,KAAK;;AAEzK;;;AAGA;AACA,2C;;;;;;;ACXA,ywD;;;;;;;ACAA,qNAAqN,kEAAkE,oBAAoB,mEAAmE,qBAAqB,wN;;;;;;;ACAnY,sEAAsE,eAAe,kJAAkJ,+bAA+b,YAAY,uEAAuE,aAAa,2qCAA2qC,kvC;;;;;;;ACAj7D,kEAAkE,eAAe,8FAA8F,uFAAuF,scAAsc,sLAAsL,eAAe,0KAA0K,MAAM,4e;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAxhC;AAE6B;AAKtE,IAAa,WAAW;IAEtB,qBAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAAI,CAAC;IAEnC,wBAAE,GAAF;QACE,MAAM,CAAC,IAAI,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imports\n\n\n// module\nexports.push([module.id, \".custom-close {\\r\\n float:right;\\r\\n}\\r\\n\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/app.component.css\n// module id = 144\n// module chunks = 1","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \"\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/book/book-detail/book-detail.component.css\n// module id = 145\n// module chunks = 1","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \".custom-close {\\r\\n float:right;\\r\\n}\\r\\n\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/book/book-list/book-list.component.css\n// module id = 146\n// module chunks = 1","exports = module.exports = require(\"../../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \"div.progress {\\r\\n margin-top: 5px;\\r\\n}\\r\\n\\r\\n.rating:hover {\\r\\n border: solid blue;\\r\\n}\\r\\n\\r\\n.selected {\\r\\n border: solid blue;\\r\\n}\\r\\n\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/rating/rating.component.css\n// module id = 147\n// module chunks = 1","module.exports = \"\\r\\n\\r\\n
\\r\\n
\\r\\n

Book Rater App

\\r\\n

Anyone can view the books.

\\r\\n

Users can view and create ratings

\\r\\n

Admins can do anything!

\\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/app.component.html\n// module id = 149\n// module chunks = 1","module.exports = \"
\\r\\n
\\r\\n \\r\\n

Title: {{selectedBook.title}}

\\r\\n
Author: {{selectedBook.author}}
\\r\\n

A quick summary of the book

\\r\\n \\r\\n
\\r\\n
\\r\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/book/book-detail/book-detail.component.html\n// module id = 150\n// module chunks = 1","module.exports = \"
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n \\r\\n

Title: {{book.title}}

\\r\\n
Author: {{book.author}}
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n

Add New Book

\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/book/book-list/book-list.component.html\n// module id = 151\n// module chunks = 1","module.exports = \"Ratings:\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n
\\r\\n \\r\\n
\\r\\n \\r\\n \\r\\n \\r\\n
\\r\\n\\r\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/rating/rating.component.html\n// module id = 152\n// module chunks = 1","import {Injectable} from \"@angular/core\";\r\nimport {Observable} from \"rxjs\";\r\nimport {Response, Http, Headers, RequestOptions} from \"@angular/http\";\r\nimport {Book} from \"./book\";\r\nimport {Rating} from \"./rating\";\r\n\r\n@Injectable()\r\nexport class HttpService {\r\n\r\n constructor(private http: Http) { }\r\n\r\n me(): Observable {\r\n return this.http.get(\"/me\", this.makeOptions())\r\n }\r\n\r\n logout(): Observable {\r\n return this.http.post(\"/logout\", '', this.makeOptions())\r\n }\r\n\r\n getBooks(): Observable {\r\n return this.http.get(\"/book-service/books\", this.makeOptions())\r\n }\r\n\r\n updateBook(newBook: Book): Observable {\r\n return this.http.put(\"/book-service/books/\" + newBook.id, newBook, this.makeOptions())\r\n }\r\n\r\n deleteBook(book: Book): Observable {\r\n return this.http.delete(\"/book-service/books/\" + book.id, this.makeOptions())\r\n }\r\n\r\n createBook(newBook: Book): Observable {\r\n return this.http.post(\"/book-service/books\", newBook, this.makeOptions())\r\n }\r\n\r\n getRatings(bookId: number): Observable {\r\n return this.http.get(\"/rating-service/ratings?bookId=\" + bookId, this.makeOptions())\r\n }\r\n\r\n createRating(rating: Rating): Observable {\r\n return this.http.post(\"/rating-service/ratings\", rating, this.makeOptions())\r\n }\r\n\r\n deleteRating(ratingId: number) {\r\n return this.http.delete(\"/rating-service/ratings/\" + ratingId, this.makeOptions())\r\n }\r\n\r\n updateRating(rating: Rating) {\r\n return this.http.put(\"/rating-service/ratings/\" + rating.id, rating, this.makeOptions())\r\n }\r\n\r\n private makeOptions(): RequestOptions {\r\n let headers = new Headers({'Content-Type': 'application/json'});\r\n return new RequestOptions({headers: headers});\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/http.service.ts","export class Principal {\r\n public authenticated: boolean;\r\n public authorities: Authority[] = [];\r\n\r\n constructor(authenticated: boolean, authorities: any[]) {\r\n this.authenticated = authenticated;\r\n authorities.map(auth => this.authorities.push(new Authority(auth.authority)))\r\n }\r\n\r\n isAdmin() {\r\n return this.authorities.some((auth: Authority) => auth.authority.indexOf('ADMIN') > -1)\r\n }\r\n}\r\n\r\nexport class Authority {\r\n public authority: String;\r\n\r\n constructor(authority: String) {\r\n this.authority = authority;\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/principal.ts","export class Book {\r\n id: number;\r\n author: String;\r\n title: String;\r\n constructor(id: number, author: String, title: String){\r\n this.id = id;\r\n this.author = author;\r\n this.title = title;\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/book.ts","function webpackEmptyContext(req) {\n\tthrow new Error(\"Cannot find module '\" + req + \"'.\");\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = 74;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src async\n// module id = 74\n// module chunks = 1","import {enableProdMode} from \"@angular/core\";\r\nimport {platformBrowserDynamic} from \"@angular/platform-browser-dynamic\";\r\nimport {AppModule} from \"./app/app.module\";\r\nimport {environment} from \"./environments/environment\";\r\n\r\nif (environment.production) {\r\n enableProdMode();\r\n}\r\n\r\nplatformBrowserDynamic().bootstrapModule(AppModule);\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/main.ts","import {Component} from \"@angular/core\";\r\nimport {Principal} from \"./principal\";\r\nimport {Response} from \"@angular/http\";\r\nimport {NgForm} from \"@angular/forms\";\r\nimport {Book} from \"./book\";\r\nimport {HttpService} from \"./http.service\";\r\n\r\n@Component({\r\n selector: 'app-root',\r\n templateUrl: './app.component.html',\r\n styleUrls: ['./app.component.css']\r\n})\r\nexport class AppComponent {\r\n selectedBook: Book = null;\r\n principal: Principal = new Principal(false, []);\r\n loginFailed: boolean = false;\r\n\r\n constructor(private httpService: HttpService){}\r\n\r\n ngOnInit(): void {\r\n this.httpService.me()\r\n .subscribe((response: Response) => {\r\n let principalJson = response.json();\r\n this.principal = new Principal(principalJson.authenticated, principalJson.authorities);\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n onLogout() {\r\n this.httpService.logout()\r\n .subscribe((response: Response) => {\r\n if (response.status === 200) {\r\n this.loginFailed = false;\r\n this.principal = new Principal(false, []);\r\n window.location.replace(response.url);\r\n }\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n closeBookDetail() {\r\n this.selectedBook = null;\r\n }\r\n\r\n selectBook(book: Book) {\r\n this.selectedBook = book;\r\n }\r\n\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/app.component.ts","import {BrowserModule} from \"@angular/platform-browser\";\r\nimport {NgModule} from \"@angular/core\";\r\nimport {FormsModule} from \"@angular/forms\";\r\nimport {HttpModule} from \"@angular/http\";\r\nimport {AppComponent} from \"./app.component\";\r\nimport {RatingComponent} from \"./rating/rating.component\";\r\nimport {ClickStopPropagationDirective} from \"./click-stop-propagation.directive\";\r\nimport {BookDetailComponent} from \"./book/book-detail/book-detail.component\";\r\nimport {BookListComponent} from \"./book/book-list/book-list.component\";\r\nimport {HttpService} from \"./http.service\";\r\n\r\n@NgModule({\r\n declarations: [\r\n AppComponent,\r\n RatingComponent,\r\n ClickStopPropagationDirective,\r\n BookDetailComponent,\r\n BookListComponent\r\n ],\r\n imports: [\r\n BrowserModule,\r\n FormsModule,\r\n HttpModule\r\n ],\r\n providers: [HttpService],\r\n bootstrap: [AppComponent]\r\n})\r\nexport class AppModule { }\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/app.module.ts","import {Component, OnInit, Input, Output, EventEmitter} from \"@angular/core\";\r\nimport {Book} from \"../../book\";\r\nimport {Principal} from \"../../principal\";\r\n\r\n@Component({\r\n selector: 'app-book-detail',\r\n templateUrl: './book-detail.component.html',\r\n styleUrls: ['./book-detail.component.css']\r\n})\r\nexport class BookDetailComponent implements OnInit {\r\n\r\n @Input() selectedBook: Book = null;\r\n @Input() principal: Principal = null;\r\n @Output() closeBook: EventEmitter = new EventEmitter();\r\n\r\n\r\n constructor() { }\r\n\r\n ngOnInit() {\r\n }\r\n\r\n closeBookDetail() {\r\n this.closeBook.emit(null);\r\n }\r\n\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/book/book-detail/book-detail.component.ts","import {Component, OnInit, Input, Output, EventEmitter} from \"@angular/core\";\r\nimport {Principal} from \"../../principal\";\r\nimport {Book} from \"../../book\";\r\nimport {Response} from \"@angular/http\";\r\nimport {HttpService} from \"../../http.service\";\r\n\r\n@Component({\r\n selector: 'app-book-list',\r\n templateUrl: './book-list.component.html',\r\n styleUrls: ['./book-list.component.css']\r\n})\r\nexport class BookListComponent implements OnInit {\r\n\r\n @Input() principal: Principal = null;\r\n @Output() onBookSelected: EventEmitter = new EventEmitter();\r\n\r\n books: Book[] = [];\r\n newBooks: Book[] = [];\r\n newBook: Book = new Book(Math.floor(Math.random() * 1000), '', '');\r\n booksToEdit: number[] = [];\r\n isAddNewBook: boolean = false;\r\n selectedBook: Book = null;\r\n\r\n constructor(private httpService: HttpService) { }\r\n\r\n ngOnInit() {\r\n this.loadBooks();\r\n }\r\n\r\n loadBooks() {\r\n this.httpService.getBooks()\r\n .subscribe((response: Response) => {\r\n let booksJson: any[] = response.json()\r\n booksJson.forEach(book => {\r\n this.books.push(new Book(book.id, book.author, book.title));\r\n this.newBooks.push(new Book(book.id, book.author, book.title));\r\n })\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n cancelEditBook(bookIndex: number) {\r\n if (this.booksToEdit.indexOf(bookIndex) !== -1) {\r\n this.booksToEdit.splice(this.booksToEdit.indexOf(bookIndex), 1); //remove the index of the book to edit\r\n //get the original book\r\n let bookCopy: Book = new Book(this.books[bookIndex].id, this.books[bookIndex].author, this.books[bookIndex].title);\r\n this.newBooks.splice(bookIndex,1,bookCopy); //replace the edited book with the old book\r\n }\r\n }\r\n\r\n editBook(bookIndex: number) {\r\n this.booksToEdit.push(bookIndex);\r\n }\r\n\r\n saveBook(bookIndex: number, newBook: Book) {\r\n console.log(newBook);\r\n //save the book to the database\r\n this.httpService.updateBook(newBook)\r\n .subscribe((response: Response) => {\r\n let bookJson = response.json();\r\n let book: Book = new Book(bookJson.id, bookJson.author, bookJson.title);\r\n //update the current array of books\r\n let bookArr: Book = this.books.find(b => b.id === book.id);\r\n bookArr.title = book.title;\r\n bookArr.author = book.author;\r\n this.booksToEdit.splice(this.booksToEdit.indexOf(bookIndex), 1); //remove the index of the book to edit\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n\r\n\r\n }\r\n\r\n delete(bookIndex: number) {\r\n let book: Book = this.books[bookIndex];\r\n this.httpService.deleteBook(book)\r\n .subscribe(() => {\r\n if (this.selectedBook !== null && this.books[bookIndex].id === this.selectedBook.id) {\r\n this.selectedBook = null;\r\n this.onBookSelected.emit(this.selectedBook);\r\n }\r\n\r\n this.books.splice(bookIndex, 1); //remove the book at this index;\r\n this.newBooks.splice(bookIndex, 1); //remove the editing book at this index\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n activateAddNewBook() {\r\n this.isAddNewBook = true;\r\n this.newBook = new Book(null, '', '');\r\n }\r\n\r\n addNewBook(newBook: Book, element: any) {\r\n //write new book to db\r\n this.httpService.createBook(newBook)\r\n .subscribe((response: Response) => {\r\n let bookJson = response.json();\r\n let book: Book = new Book(bookJson.id, bookJson.author, bookJson.title);\r\n console.log(book);\r\n this.books.push(book);\r\n this.newBooks.push(book);\r\n this.newBook = new Book(Math.floor(Math.random() * 1000), '', '');\r\n element.focus();\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n cancelAddBook() {\r\n this.isAddNewBook = false;\r\n }\r\n\r\n\r\n selectBook(book: Book) {\r\n this.selectedBook = book;\r\n this.onBookSelected.emit(book);\r\n }\r\n\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/book/book-list/book-list.component.ts","import {Directive, HostListener} from \"@angular/core\";\r\n\r\n@Directive({\r\n selector: '[appClickStopPropagation]'\r\n})\r\nexport class ClickStopPropagationDirective\r\n{\r\n @HostListener(\"click\", [\"$event\"])\r\n public onClick(event: any): void\r\n {\r\n event.stopPropagation();\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/click-stop-propagation.directive.ts","export class Rating{\r\n id: number;\r\n bookId: number;\r\n stars: number;\r\n\r\n constructor(id: number, bookId: number, stars: number) {\r\n this.id = id;\r\n this.bookId = bookId;\r\n this.stars = stars;\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/rating.ts","import {Component, OnInit, Input, OnChanges} from \"@angular/core\";\r\nimport {Rating} from \"../rating\";\r\nimport {Principal} from \"../principal\";\r\nimport {HttpService} from \"../http.service\";\r\nimport {Response} from \"@angular/http\";\r\n\r\n@Component({\r\n selector: 'app-rating',\r\n templateUrl: './rating.component.html',\r\n styleUrls: ['./rating.component.css']\r\n})\r\nexport class RatingComponent implements OnInit, OnChanges {\r\n\r\n @Input() bookId: number;\r\n @Input() principal: Principal = null;\r\n ratings: Rating[] = [];\r\n stars: number[] = [1,2,3,4,5];\r\n newRating: Rating = null;\r\n\r\n constructor(private httpService: HttpService) { }\r\n\r\n ngOnInit() {}\r\n\r\n ngOnChanges() {\r\n this.newRating = new Rating(null, this.bookId, 1);\r\n this.ratings = [];\r\n this.loadRatings();\r\n }\r\n\r\n findWidth(rating: Rating): String {\r\n let percent: number = (rating.stars/5)*100;\r\n return percent.toString() + '%';\r\n }\r\n\r\n private loadRatings() {\r\n this.httpService.getRatings(this.bookId)\r\n .subscribe((response: Response) => {\r\n let responseJson: any[] = response.json();\r\n responseJson.forEach(rating => this.ratings.push(new Rating(rating.id, rating.bookId, rating.stars)))\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n onSaveRating() {\r\n console.log(this.newRating);\r\n let ratingCopy: Rating = Object.assign({}, this.newRating);\r\n this.httpService.createRating(ratingCopy)\r\n .subscribe((response: Response) => {\r\n let ratingJson = response.json()\r\n this.ratings.push(new Rating(ratingJson.id, ratingJson.bookId, ratingJson.stars))\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n updateRating() {\r\n this.httpService.updateRating(this.newRating)\r\n .subscribe(() => {\r\n this.newRating = new Rating(null, this.bookId, 1);\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n selectRating(rating: Rating) {\r\n if (this.principal.isAdmin()) {\r\n this.newRating = rating;\r\n }\r\n }\r\n\r\n cancelSelection() {\r\n this.newRating = new Rating(null, this.bookId, 1);\r\n }\r\n\r\n deleteRating(index: number) {\r\n let rating = this.ratings[index];\r\n this.httpService.deleteRating(rating.id)\r\n .subscribe(() => {\r\n if (this.ratings[index] === this.newRating) {\r\n this.newRating = new Rating(null, this.bookId, 1);\r\n }\r\n this.ratings.splice(index, 1);\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n\r\n }\r\n\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/rating/rating.component.ts","// The file contents for the current environment will overwrite these during build.\r\n// The build system defaults to the dev environment which uses `environment.ts`, but if you do\r\n// `ng build --env=prod` then `environment.prod.ts` will be used instead.\r\n// The list of which env maps to which file can be found in `.angular-cli.json`.\r\n\r\nexport const environment = {\r\n production: false\r\n};\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/environments/environment.ts"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///./src/app/app.component.css","webpack:///./src/app/book/book-detail/book-detail.component.css","webpack:///./src/app/book/book-list/book-list.component.css","webpack:///./src/app/rating/rating.component.css","webpack:///./src/app/app.component.html","webpack:///./src/app/book/book-detail/book-detail.component.html","webpack:///./src/app/book/book-list/book-list.component.html","webpack:///./src/app/rating/rating.component.html","webpack:///./src/app/http.service.ts","webpack:///./src/app/principal.ts","webpack:///./src/app/book.ts","webpack:///./src async","webpack:///./src/main.ts","webpack:///./src/app/app.component.ts","webpack:///./src/app/app.module.ts","webpack:///./src/app/book/book-detail/book-detail.component.ts","webpack:///./src/app/book/book-list/book-list.component.ts","webpack:///./src/app/click-stop-propagation.directive.ts","webpack:///./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AC,SAAS,CAAC,CAAC,CAAC;gBAC3C,KAAI,CAAC,SAAS,GAAG,IAAI,uDAAM,CAAC,IAAI,EAAE,KAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACpD,CAAC;YACD,KAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC,EAAE,UAAC,KAAK;YACP,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IAEP,CAAC;IAEH,sBAAC;AAAD,CAAC;AA5EU;IAAR,mFAAK,EAAE;;+CAAgB;AACf;IAAR,mFAAK,EAAE;kDAAY,6DAAS,oBAAT,6DAAS;kDAAQ;AAH1B,eAAe;IAL3B,wFAAS,CAAC;QACT,QAAQ,EAAE,YAAY;QACtB,kCAAsC;QACtC,kCAAqC;KACtC,CAAC;yDASiC,kEAAW,oBAAX,kEAAW;GARjC,eAAe,CA8E3B;AA9E2B;;;;;;;;;;ACX5B;AAAA,mFAAmF;AACnF,8FAA8F;AAC9F,yEAAyE;AACzE,gFAAgF;AAEhF,mFALmF;AAK5E,IAAM,WAAW,GAAG;IACzB,UAAU,EAAE,KAAK;CAClB,CAAC","file":"main.bundle.js","sourcesContent":["exports = module.exports = require(\"../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \".custom-close {\\r\\n float:right;\\r\\n}\\r\\n\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/app.component.css\n// module id = 144\n// module chunks = 1","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \"\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/book/book-detail/book-detail.component.css\n// module id = 145\n// module chunks = 1","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \".custom-close {\\r\\n float:right;\\r\\n}\\r\\n\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/book/book-list/book-list.component.css\n// module id = 146\n// module chunks = 1","exports = module.exports = require(\"../../../node_modules/css-loader/lib/css-base.js\")();\n// imports\n\n\n// module\nexports.push([module.id, \"div.progress {\\r\\n margin-top: 5px;\\r\\n}\\r\\n\\r\\n.rating:hover {\\r\\n border: solid blue;\\r\\n}\\r\\n\\r\\n.selected {\\r\\n border: solid blue;\\r\\n}\\r\\n\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/rating/rating.component.css\n// module id = 147\n// module chunks = 1","module.exports = \"\\r\\n\\r\\n
\\r\\n
\\r\\n

Book Rater App

\\r\\n

Anyone can view the books.

\\r\\n

Users can view and create ratings

\\r\\n

Admins can do anything!

\\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/app.component.html\n// module id = 149\n// module chunks = 1","module.exports = \"
\\r\\n
\\r\\n \\r\\n

Title: {{selectedBook.title}}

\\r\\n
Author: {{selectedBook.author}}
\\r\\n

A quick summary of the book

\\r\\n \\r\\n
\\r\\n
\\r\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/book/book-detail/book-detail.component.html\n// module id = 150\n// module chunks = 1","module.exports = \"
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n \\r\\n

Title: {{book.title}}

\\r\\n
Author: {{book.author}}
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n

Add New Book

\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n
\\r\\n \\r\\n \\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/book/book-list/book-list.component.html\n// module id = 151\n// module chunks = 1","module.exports = \"Ratings:\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n\\r\\n
\\r\\n
\\r\\n \\r\\n
\\r\\n \\r\\n \\r\\n \\r\\n
\\r\\n\\r\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/app/rating/rating.component.html\n// module id = 152\n// module chunks = 1","import {Injectable} from \"@angular/core\";\r\nimport {Observable} from \"rxjs\";\r\nimport {Response, Http, Headers, RequestOptions} from \"@angular/http\";\r\nimport {Book} from \"./book\";\r\nimport {Rating} from \"./rating\";\r\n\r\n@Injectable()\r\nexport class HttpService {\r\n\r\n constructor(private http: Http) { }\r\n\r\n me(): Observable {\r\n return this.http.get(\"/me\", this.makeOptions())\r\n }\r\n\r\n logout(): Observable {\r\n return this.http.post(\"/logout\", '', this.makeOptions())\r\n }\r\n\r\n getBooks(): Observable {\r\n return this.http.get(\"/book-service/books\", this.makeOptions())\r\n }\r\n\r\n updateBook(newBook: Book): Observable {\r\n return this.http.put(\"/book-service/books/\" + newBook.id, newBook, this.makeOptions())\r\n }\r\n\r\n deleteBook(book: Book): Observable {\r\n return this.http.delete(\"/book-service/books/\" + book.id, this.makeOptions())\r\n }\r\n\r\n createBook(newBook: Book): Observable {\r\n return this.http.post(\"/book-service/books\", newBook, this.makeOptions())\r\n }\r\n\r\n getRatings(bookId: number): Observable {\r\n return this.http.get(\"/rating-service/ratings?bookId=\" + bookId, this.makeOptions())\r\n }\r\n\r\n createRating(rating: Rating): Observable {\r\n return this.http.post(\"/rating-service/ratings\", rating, this.makeOptions())\r\n }\r\n\r\n deleteRating(ratingId: number) {\r\n return this.http.delete(\"/rating-service/ratings/\" + ratingId, this.makeOptions())\r\n }\r\n\r\n updateRating(rating: Rating) {\r\n return this.http.put(\"/rating-service/ratings/\" + rating.id, rating, this.makeOptions())\r\n }\r\n\r\n private makeOptions(): RequestOptions {\r\n let headers = new Headers({'Content-Type': 'application/json'});\r\n return new RequestOptions({headers: headers});\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/http.service.ts","export class Principal {\r\n public authenticated: boolean;\r\n public authorities: Authority[] = [];\r\n\r\n constructor(authenticated: boolean, authorities: any[]) {\r\n this.authenticated = authenticated;\r\n authorities.map(auth => this.authorities.push(new Authority(auth.authority)))\r\n }\r\n\r\n isAdmin() {\r\n return this.authorities.some((auth: Authority) => auth.authority.indexOf('ADMIN') > -1)\r\n }\r\n}\r\n\r\nexport class Authority {\r\n public authority: String;\r\n\r\n constructor(authority: String) {\r\n this.authority = authority;\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/principal.ts","export class Book {\r\n id: number;\r\n author: String;\r\n title: String;\r\n constructor(id: number, author: String, title: String){\r\n this.id = id;\r\n this.author = author;\r\n this.title = title;\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/book.ts","function webpackEmptyContext(req) {\n\tthrow new Error(\"Cannot find module '\" + req + \"'.\");\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = 74;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src async\n// module id = 74\n// module chunks = 1","import {enableProdMode} from \"@angular/core\";\r\nimport {platformBrowserDynamic} from \"@angular/platform-browser-dynamic\";\r\nimport {AppModule} from \"./app/app.module\";\r\nimport {environment} from \"./environments/environment\";\r\n\r\nif (environment.production) {\r\n enableProdMode();\r\n}\r\n\r\nplatformBrowserDynamic().bootstrapModule(AppModule);\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/main.ts","import {Component} from \"@angular/core\";\r\nimport {Principal} from \"./principal\";\r\nimport {Response} from \"@angular/http\";\r\nimport {Book} from \"./book\";\r\nimport {HttpService} from \"./http.service\";\r\n\r\n@Component({\r\n selector: 'app-root',\r\n templateUrl: './app.component.html',\r\n styleUrls: ['./app.component.css']\r\n})\r\nexport class AppComponent {\r\n selectedBook: Book = null;\r\n principal: Principal = new Principal(false, []);\r\n loginFailed: boolean = false;\r\n\r\n constructor(private httpService: HttpService){}\r\n\r\n ngOnInit(): void {\r\n this.httpService.me()\r\n .subscribe((response: Response) => {\r\n let principalJson = response.json();\r\n this.principal = new Principal(principalJson.authenticated, principalJson.authorities);\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n onLogout() {\r\n this.httpService.logout()\r\n .subscribe((response: Response) => {\r\n if (response.status === 200) {\r\n this.loginFailed = false;\r\n this.principal = new Principal(false, []);\r\n window.location.replace(response.url);\r\n }\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n closeBookDetail() {\r\n this.selectedBook = null;\r\n }\r\n\r\n selectBook(book: Book) {\r\n this.selectedBook = book;\r\n }\r\n\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/app.component.ts","import {BrowserModule} from \"@angular/platform-browser\";\r\nimport {NgModule} from \"@angular/core\";\r\nimport {FormsModule} from \"@angular/forms\";\r\nimport {HttpModule} from \"@angular/http\";\r\nimport {AppComponent} from \"./app.component\";\r\nimport {RatingComponent} from \"./rating/rating.component\";\r\nimport {ClickStopPropagationDirective} from \"./click-stop-propagation.directive\";\r\nimport {BookDetailComponent} from \"./book/book-detail/book-detail.component\";\r\nimport {BookListComponent} from \"./book/book-list/book-list.component\";\r\nimport {HttpService} from \"./http.service\";\r\n\r\n@NgModule({\r\n declarations: [\r\n AppComponent,\r\n RatingComponent,\r\n ClickStopPropagationDirective,\r\n BookDetailComponent,\r\n BookListComponent\r\n ],\r\n imports: [\r\n BrowserModule,\r\n FormsModule,\r\n HttpModule\r\n ],\r\n providers: [HttpService],\r\n bootstrap: [AppComponent]\r\n})\r\nexport class AppModule { }\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/app.module.ts","import {Component, OnInit, Input, Output, EventEmitter} from \"@angular/core\";\r\nimport {Book} from \"../../book\";\r\nimport {Principal} from \"../../principal\";\r\n\r\n@Component({\r\n selector: 'app-book-detail',\r\n templateUrl: './book-detail.component.html',\r\n styleUrls: ['./book-detail.component.css']\r\n})\r\nexport class BookDetailComponent implements OnInit {\r\n\r\n @Input() selectedBook: Book = null;\r\n @Input() principal: Principal = null;\r\n @Output() closeBook: EventEmitter = new EventEmitter();\r\n\r\n\r\n constructor() { }\r\n\r\n ngOnInit() {\r\n }\r\n\r\n closeBookDetail() {\r\n this.closeBook.emit(null);\r\n }\r\n\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/book/book-detail/book-detail.component.ts","import {Component, OnInit, Input, Output, EventEmitter} from \"@angular/core\";\r\nimport {Principal} from \"../../principal\";\r\nimport {Book} from \"../../book\";\r\nimport {Response} from \"@angular/http\";\r\nimport {HttpService} from \"../../http.service\";\r\n\r\n@Component({\r\n selector: 'app-book-list',\r\n templateUrl: './book-list.component.html',\r\n styleUrls: ['./book-list.component.css']\r\n})\r\nexport class BookListComponent implements OnInit {\r\n\r\n @Input() principal: Principal = null;\r\n @Output() onBookSelected: EventEmitter = new EventEmitter();\r\n\r\n books: Book[] = [];\r\n newBooks: Book[] = [];\r\n newBook: Book = new Book(Math.floor(Math.random() * 1000), '', '');\r\n booksToEdit: number[] = [];\r\n isAddNewBook: boolean = false;\r\n selectedBook: Book = null;\r\n\r\n constructor(private httpService: HttpService) { }\r\n\r\n ngOnInit() {\r\n this.loadBooks();\r\n }\r\n\r\n loadBooks() {\r\n this.httpService.getBooks()\r\n .subscribe((response: Response) => {\r\n let booksJson: any[] = response.json()\r\n booksJson.forEach(book => {\r\n this.books.push(new Book(book.id, book.author, book.title));\r\n this.newBooks.push(new Book(book.id, book.author, book.title));\r\n })\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n cancelEditBook(bookIndex: number) {\r\n if (this.booksToEdit.indexOf(bookIndex) !== -1) {\r\n this.booksToEdit.splice(this.booksToEdit.indexOf(bookIndex), 1); //remove the index of the book to edit\r\n //get the original book\r\n let bookCopy: Book = new Book(this.books[bookIndex].id, this.books[bookIndex].author, this.books[bookIndex].title);\r\n this.newBooks.splice(bookIndex,1,bookCopy); //replace the edited book with the old book\r\n }\r\n }\r\n\r\n editBook(bookIndex: number) {\r\n this.booksToEdit.push(bookIndex);\r\n }\r\n\r\n saveBook(bookIndex: number, newBook: Book) {\r\n console.log(newBook);\r\n //save the book to the database\r\n this.httpService.updateBook(newBook)\r\n .subscribe((response: Response) => {\r\n let bookJson = response.json();\r\n let book: Book = new Book(bookJson.id, bookJson.author, bookJson.title);\r\n //update the current array of books\r\n let bookArr: Book = this.books.find(b => b.id === book.id);\r\n bookArr.title = book.title;\r\n bookArr.author = book.author;\r\n this.booksToEdit.splice(this.booksToEdit.indexOf(bookIndex), 1); //remove the index of the book to edit\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n\r\n\r\n }\r\n\r\n delete(bookIndex: number) {\r\n let book: Book = this.books[bookIndex];\r\n this.httpService.deleteBook(book)\r\n .subscribe(() => {\r\n if (this.selectedBook !== null && this.books[bookIndex].id === this.selectedBook.id) {\r\n this.selectedBook = null;\r\n this.onBookSelected.emit(this.selectedBook);\r\n }\r\n\r\n this.books.splice(bookIndex, 1); //remove the book at this index;\r\n this.newBooks.splice(bookIndex, 1); //remove the editing book at this index\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n activateAddNewBook() {\r\n this.isAddNewBook = true;\r\n this.newBook = new Book(null, '', '');\r\n }\r\n\r\n addNewBook(newBook: Book, element: any) {\r\n //write new book to db\r\n this.httpService.createBook(newBook)\r\n .subscribe((response: Response) => {\r\n let bookJson = response.json();\r\n let book: Book = new Book(bookJson.id, bookJson.author, bookJson.title);\r\n console.log(book);\r\n this.books.push(book);\r\n this.newBooks.push(book);\r\n this.newBook = new Book(Math.floor(Math.random() * 1000), '', '');\r\n element.focus();\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n cancelAddBook() {\r\n this.isAddNewBook = false;\r\n }\r\n\r\n\r\n selectBook(book: Book) {\r\n this.selectedBook = book;\r\n this.onBookSelected.emit(book);\r\n }\r\n\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/book/book-list/book-list.component.ts","import {Directive, HostListener} from \"@angular/core\";\r\n\r\n@Directive({\r\n selector: '[appClickStopPropagation]'\r\n})\r\nexport class ClickStopPropagationDirective\r\n{\r\n @HostListener(\"click\", [\"$event\"])\r\n public onClick(event: any): void\r\n {\r\n event.stopPropagation();\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/click-stop-propagation.directive.ts","export class Rating{\r\n id: number;\r\n bookId: number;\r\n stars: number;\r\n\r\n constructor(id: number, bookId: number, stars: number) {\r\n this.id = id;\r\n this.bookId = bookId;\r\n this.stars = stars;\r\n }\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/rating.ts","import {Component, OnInit, Input, OnChanges} from \"@angular/core\";\r\nimport {Rating} from \"../rating\";\r\nimport {Principal} from \"../principal\";\r\nimport {HttpService} from \"../http.service\";\r\nimport {Response} from \"@angular/http\";\r\n\r\n@Component({\r\n selector: 'app-rating',\r\n templateUrl: './rating.component.html',\r\n styleUrls: ['./rating.component.css']\r\n})\r\nexport class RatingComponent implements OnInit, OnChanges {\r\n\r\n @Input() bookId: number;\r\n @Input() principal: Principal = null;\r\n ratings: Rating[] = [];\r\n stars: number[] = [1,2,3,4,5];\r\n newRating: Rating = null;\r\n\r\n constructor(private httpService: HttpService) { }\r\n\r\n ngOnInit() {}\r\n\r\n ngOnChanges() {\r\n this.newRating = new Rating(null, this.bookId, 1);\r\n this.ratings = [];\r\n this.loadRatings();\r\n }\r\n\r\n findWidth(rating: Rating): String {\r\n let percent: number = (rating.stars/5)*100;\r\n return percent.toString() + '%';\r\n }\r\n\r\n private loadRatings() {\r\n this.httpService.getRatings(this.bookId)\r\n .subscribe((response: Response) => {\r\n let responseJson: any[] = response.json();\r\n responseJson.forEach(rating => this.ratings.push(new Rating(rating.id, rating.bookId, rating.stars)))\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n onSaveRating() {\r\n console.log(this.newRating);\r\n let ratingCopy: Rating = Object.assign({}, this.newRating);\r\n this.httpService.createRating(ratingCopy)\r\n .subscribe((response: Response) => {\r\n let ratingJson = response.json()\r\n this.ratings.push(new Rating(ratingJson.id, ratingJson.bookId, ratingJson.stars))\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n updateRating() {\r\n this.httpService.updateRating(this.newRating)\r\n .subscribe(() => {\r\n this.newRating = new Rating(null, this.bookId, 1);\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n }\r\n\r\n selectRating(rating: Rating) {\r\n if (this.principal.isAdmin()) {\r\n this.newRating = rating;\r\n }\r\n }\r\n\r\n cancelSelection() {\r\n this.newRating = new Rating(null, this.bookId, 1);\r\n }\r\n\r\n deleteRating(index: number) {\r\n let rating = this.ratings[index];\r\n this.httpService.deleteRating(rating.id)\r\n .subscribe(() => {\r\n if (this.ratings[index] === this.newRating) {\r\n this.newRating = new Rating(null, this.bookId, 1);\r\n }\r\n this.ratings.splice(index, 1);\r\n }, (error) => {\r\n console.log(error);\r\n });\r\n\r\n }\r\n\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/app/rating/rating.component.ts","// The file contents for the current environment will overwrite these during build.\r\n// The build system defaults to the dev environment which uses `environment.ts`, but if you do\r\n// `ng build --env=prod` then `environment.prod.ts` will be used instead.\r\n// The list of which env maps to which file can be found in `.angular-cli.json`.\r\n\r\nexport const environment = {\r\n production: false\r\n};\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/environments/environment.ts"],"sourceRoot":""} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/index.html b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/index.html index a01609d221..845371bb7f 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/index.html +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/index.html @@ -7,6 +7,6 @@

Book Rater

So many great things about the books

-Login +Login \ No newline at end of file diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/login.html b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/login.html deleted file mode 100644 index 92c1b35ac9..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/resources/static/login.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - Login - - -
- - - - - -
- - - \ No newline at end of file diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/LiveTest.java b/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/LiveTest.java index 4c3263b53b..04ddc0ee7a 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/LiveTest.java +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/LiveTest.java @@ -2,9 +2,8 @@ package com.baeldung.spring.cloud.bootstrap.gateway; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import io.restassured.RestAssured; +import io.restassured.authentication.FormAuthConfig; import io.restassured.config.RedirectConfig; -import io.restassured.config.SessionConfig; -import io.restassured.filter.session.SessionFilter; import io.restassured.http.ContentType; import io.restassured.response.Response; import org.junit.Assert; @@ -17,13 +16,12 @@ import static io.restassured.RestAssured.config; public class LiveTest { private final String ROOT_URI = "http://localhost:8080"; - SessionFilter sessionFilter; + private final FormAuthConfig formConfig = new FormAuthConfig("/login", "username", "password"); @Before public void setup() { - RestAssured.config = config() - .redirect(RedirectConfig.redirectConfig().followRedirects(false)) - .sessionConfig(new SessionConfig().sessionIdName("SESSION")); + RestAssured.config = config().redirect(RedirectConfig.redirectConfig() + .followRedirects(false)); } @Test @@ -35,28 +33,26 @@ public class LiveTest { @Test public void whenAccessProtectedResourceWithoutLogin_thenRedirectToLogin() { - final Response response = RestAssured.get(ROOT_URI + "/rating-service/ratings?bookId=1"); - Assert.assertEquals(HttpStatus.FORBIDDEN.value(), response.getStatusCode()); - Assert.assertNotNull(response.getBody()); + final Response response = RestAssured.get(ROOT_URI + "/home/index.html"); + Assert.assertEquals(HttpStatus.FOUND.value(), response.getStatusCode()); + Assert.assertEquals("http://localhost:8080/login", response.getHeader("Location")); } @Test public void whenAccessProtectedResourceAfterLogin_thenSuccess() { - SessionData sessionData = login("user", "password"); final Response response = RestAssured.given() - .header("X-XSRF-TOKEN", sessionData.getCsrf()) - .filter(sessionFilter) - .get(ROOT_URI + "/rating-service/ratings?bookId=1"); + .auth() + .form("user", "password", formConfig) + .get(ROOT_URI + "/book-service/books/1"); Assert.assertEquals(HttpStatus.OK.value(), response.getStatusCode()); Assert.assertNotNull(response.getBody()); } @Test public void whenAccessAdminProtectedResource_thenForbidden() { - SessionData sessionData = login("user", "password"); final Response response = RestAssured.given() - .header("X-XSRF-TOKEN", sessionData.getCsrf()) - .filter(sessionFilter) + .auth() + .form("user", "password", formConfig) .get(ROOT_URI + "/rating-service/ratings"); Assert.assertEquals(HttpStatus.FORBIDDEN.value(), response.getStatusCode()); @@ -64,10 +60,9 @@ public class LiveTest { @Test public void whenAdminAccessProtectedResource_thenSuccess() { - SessionData sessionData = login("admin", "admin"); final Response response = RestAssured.given() - .header("X-XSRF-TOKEN", sessionData.getCsrf()) - .filter(sessionFilter) + .auth() + .form("admin", "admin", formConfig) .get(ROOT_URI + "/rating-service/ratings"); Assert.assertEquals(HttpStatus.OK.value(), response.getStatusCode()); Assert.assertNotNull(response.getBody()); @@ -75,10 +70,9 @@ public class LiveTest { @Test public void whenAdminAccessDiscoveryResource_thenSuccess() { - SessionData sessionData = login("admin", "admin"); final Response response = RestAssured.given() - .header("X-XSRF-TOKEN", sessionData.getCsrf()) - .filter(sessionFilter) + .auth() + .form("admin", "admin", formConfig) .get(ROOT_URI + "/discovery"); Assert.assertEquals(HttpStatus.OK.value(), response.getStatusCode()); } @@ -88,12 +82,10 @@ public class LiveTest { final Rating rating = new Rating(1L, 4); - SessionData sessionData = login("admin", "admin"); - // request the protected resource final Response ratingResponse = RestAssured.given() - .header("X-XSRF-TOKEN", sessionData.getCsrf()) - .filter(sessionFilter) + .auth() + .form("admin", "admin", formConfig) .and() .contentType(ContentType.JSON) .body(rating) @@ -108,12 +100,10 @@ public class LiveTest { public void whenAddnewBook_thenSuccess() { final Book book = new Book("Baeldung", "How to spring cloud"); - SessionData sessionData = login("admin", "admin"); - // request the protected resource final Response bookResponse = RestAssured.given() - .header("X-XSRF-TOKEN", sessionData.getCsrf()) - .filter(sessionFilter) + .auth() + .form("admin", "admin", formConfig) .and() .contentType(ContentType.JSON) .body(book) @@ -204,60 +194,4 @@ public class LiveTest { } } - private SessionData login(String username, String password) { - sessionFilter = new SessionFilter(); - Response getLoginResponse = RestAssured.given() - .filter(sessionFilter) - .when() - .get("/login.html") - .then() - .extract() - .response(); - - String csrfToken = getLoginResponse.cookie("XSRF-TOKEN"); - - RestAssured.given().log().all(). - filter(sessionFilter) - .header("X-XSRF-TOKEN", csrfToken) - .param("username", username) - .param("password", password) - .when() - .post("/login"); - - Response afterLoginResponse = RestAssured.given() - .filter(sessionFilter) - .when() - .get("/") - .then() - .extract() - .response(); - - return new SessionData(afterLoginResponse.cookie("XSRF-TOKEN"), sessionFilter.getSessionId()); - } - - private class SessionData { - private String csrf; - private String session; - - public SessionData(String csrf, String session) { - this.csrf = csrf; - this.session = session; - } - - public String getCsrf() { - return csrf; - } - - public void setCsrf(String csrf) { - this.csrf = csrf; - } - - public String getSession() { - return session; - } - - public void setSession(String session) { - this.session = session; - } - } } \ No newline at end of file