Я настраиваю конфигурацию для HWIOAuthBundle, чтобы позволить пользователю войти в систему со своей учетной записью LinkedIn. FOSUSerBundle также используется в этом проекте. Я следовал за этими двумя уроками: https://gist.github.com/danvbe/4476697 а также http://www.diegocaprioli.com/adding-hwioauthbundle-to-your-symfony2-project/, и получил сообщение об ошибке: SSLReat () возвращает error-9806 в /Users/me/Sites/MyProject/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php в строке 29
На самом деле я уже получил токен доступа Linkedin, но не знаю, почему не могу получить профиль пользователя.
Вот моя конфигурация:
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
hwi_oauth:
connect:
confirmation: true
account_connector: my_user_provider
firewall_name: main
resource_owners:
linkedin:
type: linkedin
client_id: "MY_API_KEY"client_secret: "MY_SECRET_KEY"scope: r_fullprofile
fosub:
username_iterations: 30
properties:
linkedin: linkedin_id
fos_user:
db_driver: orm
firewall_name: main
user_class: MyProject\UserBundle\Entity\User
registration:
form:
type: myproject_user_registration
confirmation:
enabled: false
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
admin:
switch_user: true
pattern: /admin(.*)
form_login:
provider: fos_userbundle
login_path: /admin/login
use_forward: false
check_path: /admin/login_check
failure_path: null
use_referer: true
anonymous: true
logout:
path: /admin/logout
target: /admin/login
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: /login
check_path: /login_check
oauth:
login_path: /connect
failure_path: /connect
#check_path: /login_check
#provider: fos_userbundle
resource_owners:
linkedin: "/login/check-linkedin"oauth_user_provider:
service: my_user_provider
logout:
path: /logout
target: /connect
anonymous: ~
remember_me:
key: %secret%
lifetime: 7776000
path: /
domain: ~
switch_user: { role: ROLE_ADMIN }
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: %login_channel% }
- { path: ^/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/connect, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register/confirmed, role: ROLE_USER }
- { path: ^/register, role: ROLE_ADMIN, requires_channel: %register_channel% }
- { path: ^/reset-password, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/_fragment, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
- { path: ^/, role: ROLE_USER }
parameters:
security.exception_listener.class: MyProject\UserBundle\Security\Firewall\ExceptionListener
service.yml
services:
my_user_provider:
class: MyProject\UserBundle\Security\Core\User\FOSUBUserProvider
arguments: [@fos_user.user_manager,{linkedin: linkedin_id }]
routing.yml
hwi_oauth_security:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"prefix: /connect
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"prefix: /connect
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"prefix: /connect
linkedin_login:
pattern: /login/check-linkedin
fos_user_security:
resource: @FOSUserBundle/Resources/config/routing/security.xml
fos_user_profile:
resource: @FOSUserBundle/Resources/config/routing/profile.xml
prefix: /account/profile
fos_user_register:
resource: @FOSUserBundle/Resources/config/routing/registration.xml
prefix: /register
fos_user_resetting:
resource: @FOSUserBundle/Resources/config/routing/resetting.xml
prefix: /reset-password
fos_user_change_password:
resource: @FOSUserBundle/Resources/config/routing/change_password.xml
prefix: /account
fos_user_group:
resource: @FOSUserBundle/Resources/config/routing/group.xml
prefix: /group
Я пытался отладить, что идет не так, var_dump объекта LinkedinResourceOwner:
object(HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\LinkedinResourceOwner)[572]
protected 'paths' =>
array (size=5)
'identifier' => string 'id' (length=2)
'nickname' => string 'formattedName' (length=13)
'realname' => string 'formattedName' (length=13)
'email' => string 'emailAddress' (length=12)
'profilepicture' => string 'pictureUrl' (length=10)
protected 'options' =>
array (size=11)
'csrf' => boolean true
'user_response_class' => string 'HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse' (length=54)
'auth_with_one_url' => boolean false
'use_commas_in_scope' => boolean false
'use_bearer_authorization' => boolean false
'authorization_url' => string 'https://www.linkedin.com/uas/oauth2/authorization' (length=49)
'access_token_url' => string 'https://www.linkedin.com/uas/oauth2/accessToken' (length=47)
'infos_url' => string 'https://api.linkedin.com/v1/people/~:(id,formatted-name,email-address,picture-url)?format=json' (length=94)
'client_id' => string 'MY_API_KEY' (length=14)
'client_secret' => string 'MY_SECRET_KEY' (length=16)
'scope' => string 'r_fullprofile' (length=13)
protected 'httpClient' =>
object(Buzz\Client\Curl)[577]
private 'lastCurl' => resource(582, curl)
protected 'options' =>
array (size=2)
181 => int 3
182 => int 3
protected 'ignoreErrors' => boolean true
protected 'maxRedirects' => int 5
protected 'timeout' => int 5
protected 'verifyPeer' => boolean true
protected 'proxy' => null
protected 'name' => string 'linkedin' (length=8)
protected 'state' => null
protected 'storage' =>
object(HWI\Bundle\OAuthBundle\OAuth\RequestDataStorage\SessionStorage)[573]
private 'session' =>
object(Symfony\Component\HttpFoundation\Session\Session)[77]
protected 'storage' =>
object(Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage)[71]
...
private 'flashName' => string 'flashes' (length=7)
private 'attributeName' => string 'attributes' (length=10)
public 'httpUtils' =>
object(Symfony\Component\Security\Http\HttpUtils)[17]
private 'urlGenerator' =>
object(Symfony\Bundle\FrameworkBundle\Routing\Router)[14]
private 'container' =>
object(appDevDebugProjectContainer)[271]
...
protected 'matcher' =>
object(appDevUrlMatcher)[615]
...
protected 'generator' => null
protected 'context' =>
object(Symfony\Component\Routing\RequestContext)[13]
...
protected 'loader' => null
protected 'collection' => null
protected 'resource' => string '/Users/zoe/Sites/jsr/app/cache/dev/assetic/routing.yml' (length=54)
protected 'options' =>
array (size=12)
...
protected 'logger' => null
private 'urlMatcher' =>
object(Symfony\Bundle\FrameworkBundle\Routing\Router)[14]
private 'container' =>
object(appDevDebugProjectContainer)[271]
...
protected 'matcher' =>
object(appDevUrlMatcher)[615]
...
protected 'generator' => null
protected 'context' =>
object(Symfony\Component\Routing\RequestContext)[13]
...
protected 'loader' => null
protected 'collection' => null
protected 'resource' => string '/Users/me/Sites/MyProject/app/cache/dev/assetic/routing.yml' (length=54)
protected 'options' =>
array (size=12)
...
protected 'logger' => null
Задача ещё не решена.
Других решений пока нет …