Used materials from open sources
- Create Access and Refresh tokens
- Validator example
- Repository example
- Added error output for json response
Based on:
- LexikJWTAuthenticationBundle
- JWTRefreshTokenBundle
Generate ssl keys:
- $ mkdir -p config/jwt
- $ openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
- $ openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout
Don't forget about secret key Put pass phrase in config/packages/lexik_jwt_authentication.yaml
Database configuration in .env file in base directory
Generate DataBases And Tables
- php bin/console doctrine:database:create
- php bin/console doctrine:schema:update --force --complete
- php bin/console doctrine:migrations:migrate
Start
- symfony server:start
POST http://127.0.0.1:8000/auth/login {"email": "email", "password": "password", "confirmPassword": "confirmPassword"}
POST http://127.0.0.1:8000/auth/sign-up {"email": "email", "password": "password"}
POST http://127.0.0.1:8000/auth/refresh {"refresh_token": "refresh_token"}
GET http://127.0.0.1:8000/core/user Set Header - Authorization: 'access token'
Example Authorization: Bearer
PATCH http://127.0.0.1:8000/core/user Set Header - Authorization: 'access token'
Update your user - UPDATE user
SET roles
= '["ROLE_ADMIN"]' WHERE user
.id
= ;