Security Demo with Spring boot and Angular
# Start
$ docker-compose up
# Start by Detached mode: Run containers in the background, print new container names.
$ docker-compose up -d
# Stop
$ docker-compose down
# Stop & Remove image ('all': Remove all images used by any service)
$ docker-compose down --rmi all
# Angular
$ cd angular
$ yarn install
$ yarn run start
# spring boot
$ gradle bootRun
$ ./gradlew tasks --stacktrace
# spring cli
$ sdk install springboot
$ spring --version
$ spring help run
# angular cli
# gradle cli
curl --location --request POST 'http://localhost:9000/api/example' \
--header 'Content-Type: application/json' \
--header 'X-XSRF-TOKEN: a7857665-adc2-4c4e-a2af-c468bf56deea' \
--header 'Authorization: Basic dXNlcjE6dXNlcjFQYXNz' \
--data-raw '{
"name": "Sathaphorn",
"surname": "Sunthornpan"
}'
# Authorization: Basic btoa(username:password)
Remove Cookies in use on the browser.
- set proxy: for enable HttpClientXsrfModule (relative path
/api
not absolutehttp://
,https://
or methodGET
,HEAD
)
Angular platform
@Inject(PLATFORM_ID) private platform: string
. check renderingbrowser
is browser rendering andserver
is server side rendering
Angular 6 does not add X-XSRF-TOKEN header to http request
Using Angular CLI to serve over https locally