Session Cookie - ps1-ch/test GitHub Wiki

Login and save the session cookie

$ curl -c cookies.txt -s -u user:password http://localhost:8080/api/user|jq
...

Look at the cookie

$ cat cookies.txt                                                                                                       
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_localhost     FALSE   /       FALSE   0       JSESSIONID      ABDE76E229B877B7362204683574C575

Use the session cookie

$ curl -s -b cookies.txt http://localhost:8080/api/account|jq 
[
  {
    "color": 1,
    "user": {
      "password": "$2a$10$8uWwUAEEZ66bcQKzUN6HfeYMMmYCLmTrsHhzmJfDTCphBsiv/bGEe",
      "username": "user",
      "accountNonExpired": true,
      "accountNonLocked": true,
      "authorities": [
        {
          "authority": "ROLE_USER"
        }
      ],
      "credentialsNonExpired": true,
      "enabled": true
    },
    "accountName": "account1",
    "id": 1
  },
  ...