Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://www.youtube.com/watch?v=9YmPI-RUp1c
- lexik/LexikJWTAuthenticationBundle
- install
- composer require "lexik/jwt-authentication-bundle"
- Register the bundle in app/AppKernel.php
- ---------------------
- public function registerBundles()
- {
- return array(
- //...
- new Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBUndle(), //za symfony 3
- );
- }
- ---------------------------
- Generate the SSH keys
- ---------------------------
- config.yml
- lexik_jwt_authentication:
- private_key_path: '%jwt_private_key_path%' - '%kernel.root_dir%/../var/jwt/private.pem
- public_key_path: '%jwt_public_key_path%' - '%kernel.root_dir%/../var/jwt/public.pem
- pass_phrase: '%jwt_key_pass_phrase%' -jwt_key_pass_phrase ubacujemo u parameters
- token_ttl: '%jwt_token_ttl%' = 3600
- -------------------------
- security.yml
- security:
- #...
- firewalls:
- login:
- pattern: ^/api/login
- stateless: true
- anonymous: true
- form_login:
- check_login: /api/login_check
- username_parameter: username
- password_parameter: password
- success_handler: lexik_jwt_authentication.handler.authentication_success
- failure_handler: lexik_jwt_authentication.handler.authentication_failure
- api:
- pattern: ^/api
- stateless: true
- provider: fos_userbundle
- guard:
- authenticators:
- - lexik_jwt_authentication.jwt_token_authenticator
- access_control:
- - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
- ---------------------------------------
- routing.yml
- api_login_check:
- path: /api/login_check
- ----------------------------------
- http://localhost:800/api/login_check
- in postman x-www-form-urlencoded
- username -> aaaa
- password -> aaaa
- -----------------------------
- for get in postman
- Headers
- *Authorization -> Bearer token - token bez navodnika
Add Comment
Please, Sign In to add comment