Commit baa293fd authored by i.vasilenko@iq-adv.ru's avatar i.vasilenko@iq-adv.ru
Browse files

login & register

parent b1c18596
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ framework:

    #esi: true
    #fragments: true
    serializer:
        name_converter: serializer.name_converter.camel_case_to_snake_case

when@test:
    framework:
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@ lexik_jwt_authentication:
    secret_key: '%env(resolve:JWT_SECRET_KEY)%'
    public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
    pass_phrase: '%env(JWT_PASSPHRASE)%'
    token_ttl: 3600
+24 −2
Original line number Diff line number Diff line
@@ -4,14 +4,33 @@ security:
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
    # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
    providers:
        users_in_memory: { memory: null }
        # used to reload user from session & other features (e.g. switch_user)
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email
    firewalls:
        login:
            pattern: ^/api/login
            stateless: true
            json_login:
                check_path: /api/login
                username_path: email
                password_path: password
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure

        api:
            pattern: ^/api
            stateless: true
            jwt: ~

        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            lazy: true
            provider: users_in_memory
            provider: app_user_provider

            # activate different ways to authenticate
            # https://symfony.com/doc/current/security.html#the-firewall
@@ -22,6 +41,9 @@ security:
    # Easy way to control access for large sections of your site
    # Note: Only the *first* access control that matches will be used
    access_control:
        - { path: ^/api/login, roles: PUBLIC_ACCESS }
        - { path: ^/api/register, roles: PUBLIC_ACCESS }
        - { path: ^/api,       roles: ROLE_CONFIRMED }
        # - { path: ^/admin, roles: ROLE_ADMIN }
        # - { path: ^/profile, roles: ROLE_USER }

+3 −0
Original line number Diff line number Diff line
@@ -3,3 +3,6 @@ controllers:
        path: ../src/Controller/
        namespace: App\Controller
    type: attribute

api_login:
    path: /api/login
 No newline at end of file
+44 −2
Original line number Diff line number Diff line
@@ -20,5 +20,47 @@ services:
            - '../src/Entity/'
            - '../src/Kernel.php'

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones
    # Сервисы действий
    App\Service\Action\ActionServiceInterface $registerService: '@App\Service\Action\Classes\Register'

    App\Service\Action\ActionServiceInterface: '@App\Service\Action\Classes\None'


    # Сервисы Dto
    App\Service\Dto\DtoServiceInterface $registerDto: '@App\Service\Dto\Classes\RegisterDto'

    App\Service\Dto\DtoServiceInterface: '@App\Service\Dto\Classes\NoneDto'


    # Сервисы ответа
    App\Service\Response\ResponseServiceInterface $profileResponse: '@App\Service\Response\Classes\ProfileResponse'

    App\Service\Response\ResponseServiceInterface: '@App\Service\Response\Classes\Response'



    # События JWT авторизации
    acme_api.event.authentication_success_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_success, method: onAuthenticationSuccessResponse }

    acme_api.event.authentication_failure_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_failure, method: onAuthenticationFailureResponse }

    acme_api.event.jwt_invalid_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_invalid, method: onJWTInvalid }

    acme_api.event.jwt_notfound_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_not_found, method: onJWTNotFound }

    acme_api.event.jwt_expired_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_expired, method: onJWTExpired }
 No newline at end of file
Loading