$ cd app/auth
$ npm install --save cookie-session @types/cookie-session
$ cd app/auth
$ npm install --save jsonwebtoken @types/jsonwebtoken
$ curl \
--insecure \
--cookie-jar /tmp/cookies.txt \
--data '{"email":"marley6@example.com", "password":"123456789"}' \
--header "Content-Type: application/json" \
--request POST https://ticketing.dev/api/users/signup \
| python -m json.tool
$ cat /tmp/cookies.txt
#HttpOnly_ticketing.dev FALSE / TRUE 0 express:sess eyJqd3QiOiJleUpoYkdjaU9pSklVekkxTmlJc0luUjVjQ0k2SWtwWFZDSjkuZXlKcFpDSTZJalZsWWpVMk56RmpPV0kwTmpObU1ERmhPVGN5TWprME5TSXNJbVZ0WVdsc0lqb2liV0Z5YkdWNU5rQmxlR0Z0Y0d4bExtTnZiU0lzSW1saGRDSTZNVFU0T0RrME5qY3hObjAuS3ZzV2NLbVN6VmNlWEhrdFFNNnU3cGtxWlFETVU2NC0tMGlPWTlVcE5mQSJ9
decode
{"jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVlYjU2NzFjOWI0NjNmMDFhOTcyMjk0NSIsImVtYWlsIjoibWFybGV5NkBleGFtcGxlLmNvbSIsImlhdCI6MTU4ODk0NjcxNn0.KvsWcKmSzVceXHktQM6u7pkqZQDMU64--0iOY9UpNfA"}
decode with key: 'asdf'
response:
{
"id": "5eb5671c9b463f01a9722945",
"email": "marley6@example.com",
"iat": 1588946716
}
$ kubectl create secret generic jwt-secret --from-literal=JWT_KEY=asdf
$ kubectl get secrets
NAME TYPE DATA AGE
default-token-dmr6t kubernetes.io/service-account-token 3 2d9h
jwt-secret Opaque 1 7s
$ curl \
--data '{"email":"marley7@example.com", "password":"123456789"}' \
--header "Content-Type: application/json" \
--request POST http://ticketing.dev/api/users/signup \
| python -m json.tool
response:
{
"email": "marley7@example.com",
"id": "5eb5997b5fcfb902b17eefc6"
}
$ curl \
--data '{"email":"marley7@example.com", "password":"123456789"}' \
--header "Content-Type: application/json" \
--request POST http://ticketing.dev/api/users/signin \
| python -m json.tool
response:
{
"email": "marley7@example.com",
"id": "5eb5997b5fcfb902b17eefc6"
}
// SIGN UP
$ curl \
--insecure \
--cookie-jar /tmp/cookies.txt \
--data '{"email":"marley@example.com", "password":"123456789"}' \
--header "Content-Type: application/json" \
--request POST https://ticketing.dev/api/users/signup \
| python -m json.tool
// SIGN IN
$ curl \
--data '{"email":"marley@example.com", "password":"123456789"}' \
--header "Content-Type: application/json" \
--request POST http://ticketing.dev/api/users/signin \
| python -m json.tool
// GET CURRENT USER
$ curl \
--insecure \
--cookie /tmp/cookies.txt \
--header "Content-Type: application/json" \
--request GET https://ticketing.dev/api/users/currentuser \
| python -m json.tool
response:
{
"currentUser": {
"email": "marley@example.com",
"iat": 1588965708,
"id": "5eb5b14c97bd760b4fc2c798"
}
}
Marley
Any questions in english: Telegram Chat
Любые вопросы на русском: Телеграм чат