Интеграция Gitlab, обеспечивающая проблему аутентификации в symfony - PullRequest
1 голос
/ 22 января 2020

Я пытаюсь внедрить Gitlab аутентификацию в моем Symfony проекте. Это список моих файлов.

GitlabAuthController. php

/**
 * Class GitlabAuthController.
 * @Route("/api")
 */
class GitlabAuthController extends AbstractController
{
    /**
     * Link to this controller to start the "connect" process.
     *
     * @Route("/connect/gitlab", name="connect_gitlab_start")
     *
     * @param ClientRegistry $clientRegistry
     *
     * @return RedirectResponse
     */
    public function connectAction(ClientRegistry $clientRegistry): RedirectResponse
    {

        // will redirect to gitlab!
        return $clientRegistry
            ->getClient('gitlab') // key used in config/packages/knpu_oauth2_client.yaml
            ->redirect()
            ;
    }

security.yaml

security:
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        app_user_provider:
            id: App\Security\UserProvider
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: lazy

    access_control:
        - { path: ^/api/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/, roles: ROLE_USER }

Но я получаю следующую ошибку:

Full authentication is required to access this resource.

Может кто-нибудь помочь мне решить эту проблему.

Спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...