FriendsOfSymfony / FOSOAuthServerBundle

A server side OAuth2 Bundle for Symfony
1.09k stars 451 forks source link

Controller "fos_oauth_server.controller.authorize" does neither exist as service nor as class #607

Open zpete opened 5 years ago

zpete commented 5 years ago

Hi. I try to use FOSOAuthServerBundle in Symfony 4. I use dev-master and get the following error when accessing the route oauth/v2/auth

Controller "fos_oauth_server.controller.authorize" does neither exist as service nor as class

Error
Class 'fos_oauth_server.controller.authorize' not found

My Configs:

# app/config/config.yml
fos_oauth_server:
  db_driver: orm
  client_class:        App\OAuth2\Entity\Client
  access_token_class:  App\OAuth2\Entity\AccessToken
  refresh_token_class: App\OAuth2\Entity\RefreshToken
  auth_code_class:     App\OAuth2\Entity\AuthCode
  authorize: false
  service:
    user_provider: platform.user.provider
    options:
      supported_scopes: user
# security.yml

security:
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        user_provider:
            id: platform.user.provider

    encoders:
        App\OAuth2\Entity\User:
            algorithm:        sha1
            encode_as_base64: false
            iterations:       1

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        oauth_token:
            pattern:    ^/oauth/v2/token
            security:   false

        oauth_auth:
            pattern:    ^/oauth/v2/auth
            security:   false

        api:
            pattern:    ^/api
            fos_oauth:  true
            stateless:  true

    access_control:
        - { path: ^/api, roles: [ IS_AUTHENTICATED_FULLY ] }
# routes.yml

fos_oauth_server_token:
  resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml"

fos_oauth_server_authorize:
  resource: "@FOSOAuthServerBundle/Resources/config/routing/authorize.xml"
# services.yml

 # OAuth2
    #
    platform.user.manager:
        class: Doctrine\ORM\EntityManager
        factory: ['@doctrine','getManagerForClass']
        arguments: ['App\OAuth2\Entity\User']

    platform.user.repository:
        class: App\OAuth2\Repository\UserRepository
        factory: ['@platform.user.manager','getRepository']
        arguments: ['App\OAuth2\Entity\User']

    platform.user.provider:
        class: App\OAuth2\Provider\UserProvider
        arguments: ['@platform.user.repository']

Any idea why the controller could not be found?

Thanks a lot!

konshensx16 commented 5 years ago

Hello there mate, I hope you're doing well :)

I just wanted to ask you if you ever solved this, I'm getting a similar error in Symfony 4 and I've been through the whole documentation but couldn't find anything (Unless I'm not looking in the correct place)

Thanks in advance :)

506574657220426F656C650D commented 5 years ago

try fos_oauth_server: authorize: true