Edit: An error was detected. In \ vendor \ friendsofsymfony \ oauth-server-bundle \ FOS \ OAuthServerBundle \ Resources \ config \ oauth.xml there is a small little code that says:
<argument type="service" id="fos_oauth_server.user_provider" on-invalid="null" />
Therefore, when the service definition in config.yml is incorrect or just a typo (from the original documents )
If you're authenticating users, don't forget to set the user provider. Here an example using the FOSUserBundle user provider:
fos_oauth_server:
...
service:
user_provider: fos_user.user_manager
you are lost. There is no error, no warnings, the user provider is simply empty. Thanks for reading this post. I will talk about this on github.
-
I am creating an OAuth2 server with FOSOAuthServerBundle . Everything works and works while I request access_token with grant_type = password and use form_login with a custom UserProvider.
My security.yml is as follows.
security:
providers:
webservice:
id: webservice_user_provider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
oauth_authorize:
pattern: ^/oauth/v2/auth
form_login:
provider: webservice
check_path: login_check
login_path: login
anonymous: true
oauth_token:
pattern: ^/oauth/v2/token
security: false
api:
pattern: ^/api
fos_oauth: true
stateless: true
default:
anonymous: ~
form_login:
provider: webservice
login_path: /login
check_path: /login_check
logout:
path: /logout
target: /
login:
pattern: ^/login$
security: false
, . , . security.yml
oauth_authorize:
pattern: ^/oauth/v2/auth
webservice-login:
provider: webservice
check_path: login_check
login_path: /login
anonymous: true
webservice-login:
check_path: login_check
login_path: /login
provider: webservice
webservice-login SecurityFactory
class SecurityFactory extends FormLoginFactory
{
public function getKey()
{
return 'webservice-login';
}
protected function getListenerId()
{
return 'security.authentication.listener.form';
}
protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId)
{
$provider = 'security.authentication_provider.als_webservice.'.$id;
$container
->setDefinition($provider, new DefinitionDecorator('security.authentication_provider.als_webservice'))
->replaceArgument(1, new Reference($userProviderId))
->replaceArgument(3, $id)
;
return $provider;
}
}
, : : - loadUserByUsername() - \friendsofsymfony\oauth-server-bundle\FOS\OAuthServerBundle\Storage\OAuthStorage.php 165. UserProvider null.
- , ? , !