From ccfb621c2b8b0714e903eb932b11b59be23d5d8b Mon Sep 17 00:00:00 2001 From: Lang Date: Wed, 21 Dec 2016 16:15:25 +0100 Subject: [PATCH] bugfix hwioauth remember me && centralize hwioauth and facebook settings --- app/config/config.yml | 23 ++++++++++++++---- app/config/config_dev.yml | 16 ++----------- app/config/config_prod.yml | 16 ++----------- app/config/security.yml | 10 ++++++-- .../UserBundle/Resources/config/routing.yml | 3 +++ .../UserBundle/Resources/config/services.yml | 2 +- .../Resources/views/layout.html.twig | 24 +++++++------------ 7 files changed, 44 insertions(+), 50 deletions(-) diff --git a/app/config/config.yml b/app/config/config.yml index c6ecc34..ce6cb01 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -28,10 +28,10 @@ framework: trusted_hosts: ~ trusted_proxies: ~ session: - # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id +# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id # handler_id: session.handler.native_file handler_id: session.handler.pdo - save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%" +# save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%" fragments: ~ http_method_override: true assets: ~ @@ -41,8 +41,9 @@ twig: debug: "%kernel.debug%" strict_variables: "%kernel.debug%" globals: - version: "0.27.16 (beta4)" + version: "0.29.18 (beta6)" facebook_api: "%facebook.api%" + facebook_scope: "%facebook.scope%" facebook_api_version: "%facebook.version%" # Doctrine Configuration @@ -84,9 +85,23 @@ assetic: # FOS User Configuration fos_user: db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel' - firewall_name: main + firewall_name: secured_area user_class: Jotunheimr\UserBundle\Entity\User +# Facebook OAuth +hwi_oauth: + firewall_names: [secured_area] + resource_owners: + facebook: + type: facebook + client_id: "%facebook.api%" + client_secret: "%facebook.api-secret%" + scope: "%facebook.scope%" + options: + display: popup + auth_type: rerequest + csrf: true + # Slack integration cl_slack: api_token: xoxp-107639806167-107029084564-115427085733-cccaa4f96c89c87ce680c7f22acfd001 diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml index 2eed480..dbd148d 100644 --- a/app/config/config_dev.yml +++ b/app/config/config_dev.yml @@ -34,19 +34,7 @@ monolog: parameters: facebook.api: 320599508311862 + facebook.api-secret: 18d4f48cdd274bccee2678e5eff3f557 facebook.version: 'v2.8' + facebook.scope: 'public_profile,email,user_friends' mineseeker.websocket: 6450 - -# Facebook OAuth -hwi_oauth: - firewall_names: [secured_area] - resource_owners: - facebook: - type: facebook - client_id: 320599508311862 - client_secret: 18d4f48cdd274bccee2678e5eff3f557 - scope: "public_profile,email" - options: - display: popup - auth_type: rerequest - csrf: true diff --git a/app/config/config_prod.yml b/app/config/config_prod.yml index 9be8bae..e6e9d05 100644 --- a/app/config/config_prod.yml +++ b/app/config/config_prod.yml @@ -25,19 +25,7 @@ monolog: parameters: facebook.api: 320597498312063 + facebook.api-secret: c751bec8a3c5313ff2e5a83769bf1109 facebook.version: 'v2.8' + facebook.scope: 'public_profile,email,user_friends' mineseeker.websocket: 8080 - -# Facebook OAuth -hwi_oauth: - firewall_names: [secured_area] - resource_owners: - facebook: - type: facebook - client_id: 320597498312063 - client_secret: c751bec8a3c5313ff2e5a83769bf1109 - scope: "public_profile,email" - options: - display: popup - auth_type: rerequest - csrf: true diff --git a/app/config/security.yml b/app/config/security.yml index 2fe5f50..7c2df6d 100644 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -21,13 +21,19 @@ security: login_path: /login failure_path: /login use_forward: false - oauth_user_provider: - service: my.custom.user_provider + service: jotun.user_provider + remember_me: + secret: "%secret%" + lifetime: 604800 + path: / + domain: ~ + user_provider: fos_userbundle form_login: provider: fos_userbundle csrf_token_generator: security.csrf.token_manager default_target_path: / + remember_me: true logout: path: /logout target: / diff --git a/src/Jotunheimr/UserBundle/Resources/config/routing.yml b/src/Jotunheimr/UserBundle/Resources/config/routing.yml index dec8e06..b86b039 100644 --- a/src/Jotunheimr/UserBundle/Resources/config/routing.yml +++ b/src/Jotunheimr/UserBundle/Resources/config/routing.yml @@ -9,9 +9,12 @@ hwi_oauth_login: facebook_login: path: /login/check-facebook + defaults: { _remember_me: on } google_login: path: /login/check-google + defaults: { _remember_me: on } github_login: path: /login/check-github + defaults: { _remember_me: on } diff --git a/src/Jotunheimr/UserBundle/Resources/config/services.yml b/src/Jotunheimr/UserBundle/Resources/config/services.yml index 09f88f9..9036719 100644 --- a/src/Jotunheimr/UserBundle/Resources/config/services.yml +++ b/src/Jotunheimr/UserBundle/Resources/config/services.yml @@ -1,4 +1,4 @@ services: - my.custom.user_provider: + jotun.user_provider: class: Jotunheimr\UserBundle\Security\Core\User\MyFOSUBUserProvider arguments: ['@fos_user.user_manager', { facebook: facebookId }, '@doctrine.orm.entity_manager'] diff --git a/src/Jotunheimr/UserBundle/Resources/views/layout.html.twig b/src/Jotunheimr/UserBundle/Resources/views/layout.html.twig index 2ea945d..dc2409f 100644 --- a/src/Jotunheimr/UserBundle/Resources/views/layout.html.twig +++ b/src/Jotunheimr/UserBundle/Resources/views/layout.html.twig @@ -40,23 +40,17 @@ $(document).snowfall({deviceorientation: true, round: true, minSize: 5, maxSize: 8}); $('#fbLogin').length && $('#fbLogin').on('click', function () { - FB.login(function (response) { - if (response.authResponse) { + FB.getLoginStatus(function (response) { + if (response.status === 'connected') { document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}"; + } else { + FB.login(function (response) { + if (response.authResponse) { + document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}"; + } + }, {scope: '{{ facebook_scope }}'}); } - }, {scope: 'email'}); - - {#FB.getLoginStatus(function (response) {#} - {#if (response.status === 'connected') {#} - {#document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}";#} - {#} else {#} - {#FB.login(function (response) {#} - {#if (response.authResponse) {#} - {#document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}";#} - {#}#} - {#}, {scope: 'email'});#} - {#}#} - {#});#} + }); }); });