Browse Source

Merge branch 'oauth' of https://bitbucket.org/ikflowdat/ftth into fsm_onu_v1

Conflicts:
	app/AppKernel.php
	app/config/config.yml
	app/config/routing.yml
	composer.json
	composer.lock
Maximiliano Schvindt 8 năm trước cách đây
mục cha
commit
624c1df633

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 /app/config/parameters.yml
+/app/config/hwioauthbundle/parameters.yml
 /build/
 /phpunit.xml
 /var/*

+ 3 - 1
app/AppKernel.php

@@ -27,7 +27,9 @@ class AppKernel extends Kernel
             new JMS\SerializerBundle\JMSSerializerBundle($this),
             new Nelmio\CorsBundle\NelmioCorsBundle(),
             new Base\AdminBundle\BaseAdminBundle(),
-            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle()
+            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
+            new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
+            new Base\OAuthBundle\BaseOAuthBundle()
         ];
 
         if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {

+ 11 - 9
app/config/config.yml

@@ -7,9 +7,11 @@ imports:
     - { resource: "@FTTHBundle/Resources/config/services.yml" }
     - { resource: "@WebserviceBundle/Resources/config/services.yml" }
     - { resource: workflow.yml }
+    - { resource: "hwioauthbundle/parameters.yml" }
+    - { resource: "@BaseOAuthBundle/Resources/config/services.yml" }
+    - { resource: "@BaseOAuthBundle/Resources/config/hwioauthbundle/services.yml" }
+    - { resource: "@BaseOAuthBundle/Resources/config/hwioauthbundle/config.yml" }
 
-# Put parameters here that don't need to change on each machine where the app is deployed
-# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
 parameters:
     locale: es
 
@@ -29,6 +31,7 @@ framework:
     trusted_hosts:   ~
     trusted_proxies: ~
     session:
+        name: ftth_session
         # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
         handler_id:  session.handler.native_file
         save_path:   "%kernel.root_dir%/../var/sessions/%kernel.environment%"
@@ -55,12 +58,6 @@ doctrine:
         user:     "%database_user%"
         password: "%database_password%"
         charset:  UTF8
-        # if using pdo_sqlite as your database driver:
-        #   1. add the path in parameters.yml
-        #     e.g. database_path: "%kernel.root_dir%/../var/data/data.sqlite"
-        #   2. Uncomment database_path in parameters.yml.dist
-        #   3. Uncomment next line:
-        #path:     "%database_path%"
 
     orm:
         auto_generate_proxy_classes: "%kernel.debug%"
@@ -90,4 +87,9 @@ sonata_block:
     default_contexts: [sonata_page_bundle]
     blocks:
         sonata.admin.block.admin_list:
-            contexts:   [admin]
+            contexts:   [admin]
+
+sonata_admin:
+    templates:
+        layout: BaseAdminBundle::standard_layout.html.twig
+        user_block: BaseOAuthBundle:Core:oauth_user_block.html.twig

+ 2 - 2
app/config/hwioauthbundle/parameters.yml

@@ -1,6 +1,6 @@
 parameters:
-    client_id: 1_4mjan6zlzlwkogsw4kgkco4cgso4swwc0o880gk0wkgoggkoko
-    client_secret: 42ksnazex7eo4oswgk800kk44w8o04cgco8gcoc4ocoow004os
+    client_id: 2_69u0epm6clk4w8kw8sw8c4so88404go80wc08oc4co0gsoo0cg
+    client_secret: 1eji8ahod9k0oo8ows0c0oookwsg8gg0wkw0c0so0wkowgg0o0
     access_token_url:    "http://200.50.175.17/base/app_dev.php/oauth/v2/token"
     authorization_url:   "http://200.50.175.17/base/app_dev.php/oauth/v2/auth"
     infos_url:           "http://200.50.175.17/base/app_dev.php/api/user/me"

+ 6 - 0
app/config/hwioauthbundle/parameters.yml.dist

@@ -0,0 +1,6 @@
+parameters:
+    client_id:           "5_4pweqwos4jy8wokw0cssks04gg4k04o0ccgcskc0ow0skg88s0"
+    client_secret:       "26gqveoflockc88w88gsc0o0kow404wo8ww8s4gkk08c0c44g0"
+    access_token_url:    "http://200.50.168.111/base/app_dev.php/oauth/v2/token"
+    authorization_url:   "http://200.50.168.111/base/app_dev.php/oauth/v2/auth"
+    infos_url:           "http://200.50.168.111/base/app_dev.php/api/user/me"

+ 1 - 0
app/config/parameters.yml.dist

@@ -17,3 +17,4 @@ parameters:
 
     # A secret key that's used to generate certain security-related tokens
     secret:            ThisTokenIsNotSoSecretChangeIt
+    jms_serializer.camel_case_naming_strategy.class: JMS\Serializer\Naming\IdenticalPropertyNamingStrategy

+ 24 - 1
app/config/routing.yml

@@ -1,3 +1,20 @@
+login:
+    path: /admin/login
+    defaults:
+        _controller: FrameworkBundle:Redirect:urlRedirect
+        path: /connect/login
+        permanent: true
+
+logout:
+    path: /logout
+
+homepage:
+    path: /
+    defaults:
+        _controller: FrameworkBundle:Redirect:urlRedirect
+        path: /admin/dashboard
+        permanent: true
+
 ftth_onu_api:
     resource: "@FTTHBundle/Controller/ONURESTController.php"
     type:   rest
@@ -16,4 +33,10 @@ _sonata:
 
 FTTHBundle:
     resource: "@FTTHBundle/Resources/config/routing/admin.xml"
-    prefix: /admin    
+    prefix: /admin    
+    
+base_oauth:
+    resource: "@BaseOAuthBundle/Resources/config/routing.yml"
+    
+base_hwioauthbundle_oauth:
+    resource: "@BaseOAuthBundle/Resources/config/hwioauthbundle/routing.yml"

+ 28 - 18
app/config/security.yml

@@ -1,24 +1,34 @@
-# To get started with security, check out the documentation:
-# http://symfony.com/doc/current/security.html
 security:
-
-    # http://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
+    
     providers:
-        in_memory:
-            memory: ~
-
+        oauth:
+            id: base_oauth_bundle.oauth_user_provider
+    
+    role_hierarchy:
+        ROLE_ADMIN: [ROLE_USER, ROLE_ALLOWED_TO_SWITCH]
+        ROLE_SUPER_ADMIN: ROLE_ADMIN
+            
     firewalls:
-        # disables authentication for assets and the profiler, adapt it according to your needs
         dev:
             pattern: ^/(_(profiler|wdt)|css|images|js)/
             security: false
-
-        main:
-            anonymous: ~
-            # activate different ways to authenticate
-
-            # http_basic: ~
-            # http://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
-
-            # form_login: ~
-            # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
+        secured_area:
+            pattern: ^/
+            logout:
+                path:   /logout
+                target: /
+            anonymous: true
+            
+            # HWIOAuthBundle + BaseOAuthBundle Configuration
+            oauth:
+                login_path: /login
+                failure_path: /login
+                check_path: /login
+                resource_owners:
+                    login: /login_check
+                oauth_user_provider:
+                    service: base_oauth_bundle.oauth_user_provider
+                    
+    access_control:
+        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
+        - { path: ^/admin/, role: ROLE_ADMIN }

+ 10 - 1
composer.json

@@ -30,6 +30,13 @@
             "options": {
                     "local_pk": "./keys/bitbucket.id_rsa"
             }
+        },
+        {
+            "type": "vcs",
+            "url":  "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseOAuthBundle.git",
+            "options": {
+                    "local_pk": "./keys/bitbucket.id_rsa"
+            }
         }
     ],
     "config":{
@@ -55,7 +62,9 @@
         "voryx/restgeneratorbundle": "dev-master",
         "base-admin": "dev-master",
         "webservice": "dev-master",
-        "symfony/workflow": "^3.2"
+        "symfony/workflow": "^3.2",
+        "base-oauth-bundle": "dev-master",
+        "hwi/oauth-bundle": "^0.5.3"
     },
     "require-dev": {
         "sensio/generator-bundle": "^3.0",

+ 306 - 2
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "1671fadae97d90681f342b5786cd9642",
+    "content-hash": "85cffcdcb1327dc9386c24deefbdece8",
     "packages": [
         {
             "name": "base-admin",
@@ -29,6 +29,33 @@
             ],
             "time": "2017-03-08 18:28:07"
         },
+        {
+            "name": "base-oauth-bundle",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseOAuthBundle.git",
+                "reference": "2e743e8256659cde7cc77bf1bf258961053df926"
+            },
+            "require": {
+                "friendsofsymfony/oauth-server-bundle": "^1.5",
+                "hwi/oauth-bundle": "^0.5.3"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Base\\OAuthBundle\\": ""
+                }
+            },
+            "description": "Flowdat 3 Base OAuth Bundle",
+            "keywords": [
+                "Admin Generator",
+                "admin",
+                "bundle",
+                "oauth"
+            ],
+            "time": "2017-03-03 14:18:01"
+        },
         {
             "name": "behat/transliterator",
             "version": "v1.1.0",
@@ -902,6 +929,132 @@
             ],
             "time": "2016-12-18T15:42:34+00:00"
         },
+        {
+            "name": "friendsofsymfony/oauth-server-bundle",
+            "version": "1.5.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/FriendsOfSymfony/FOSOAuthServerBundle.git",
+                "reference": "0b25cdaae8983c630bb62d14b6993219b1dadb8d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/FriendsOfSymfony/FOSOAuthServerBundle/zipball/0b25cdaae8983c630bb62d14b6993219b1dadb8d",
+                "reference": "0b25cdaae8983c630bb62d14b6993219b1dadb8d",
+                "shasum": ""
+            },
+            "require": {
+                "friendsofsymfony/oauth2-php": "~1.1",
+                "php": "^5.3.3|^7.0",
+                "symfony/framework-bundle": "~2.2|~3.0",
+                "symfony/security-bundle": "~2.1|~3.0"
+            },
+            "require-dev": {
+                "doctrine/doctrine-bundle": "~1.0",
+                "doctrine/mongodb-odm": "~1.0",
+                "doctrine/orm": "~2.2",
+                "phing/phing": "~2.4",
+                "propel/propel1": "^1.6.5",
+                "symfony/class-loader": "~2.1|~3.0",
+                "symfony/form": "~2.3|~3.0",
+                "symfony/yaml": "~2.1|~3.0",
+                "willdurand/propel-typehintable-behavior": "^1.0.4"
+            },
+            "suggest": {
+                "doctrine/doctrine-bundle": "*",
+                "doctrine/mongodb-odm-bundle": "*",
+                "propel/propel-bundle": "If you want to use Propel with Symfony2, then you will have to install the PropelBundle",
+                "symfony/form": "Needed to be able to use the AuthorizeFormType",
+                "willdurand/propel-typehintable-behavior": "The Typehintable behavior is useful to add type hints on generated methods, to be compliant with interfaces"
+            },
+            "type": "symfony-bundle",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.5-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "FOS\\OAuthServerBundle\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Arnaud Le Blanc",
+                    "email": "arnaud.lb@gmail.com"
+                },
+                {
+                    "name": "FriendsOfSymfony Community",
+                    "homepage": "https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/contributors"
+                }
+            ],
+            "description": "Symfony2 OAuth Server Bundle",
+            "homepage": "http://friendsofsymfony.github.com",
+            "keywords": [
+                "oauth",
+                "oauth2",
+                "server"
+            ],
+            "time": "2016-02-22T13:57:55+00:00"
+        },
+        {
+            "name": "friendsofsymfony/oauth2-php",
+            "version": "1.2.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/FriendsOfSymfony/oauth2-php.git",
+                "reference": "fa2aecb1fca2a03fd5f9aca19fe9adb9dfff928c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/FriendsOfSymfony/oauth2-php/zipball/fa2aecb1fca2a03fd5f9aca19fe9adb9dfff928c",
+                "reference": "fa2aecb1fca2a03fd5f9aca19fe9adb9dfff928c",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.2",
+                "symfony/http-foundation": "~2.0|~3.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.2.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "OAuth2\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Arnaud Le Blanc",
+                    "email": "arnaud.lb@gmail.com"
+                },
+                {
+                    "name": "FriendsOfSymfony Community",
+                    "homepage": "https://github.com/FriendsOfSymfony/oauth2-php/contributors"
+                }
+            ],
+            "description": "OAuth2 library",
+            "homepage": "https://github.com/FriendsOfSymfony/oauth2-php",
+            "keywords": [
+                "oauth",
+                "oauth2"
+            ],
+            "time": "2016-03-31T14:24:17+00:00"
+        },
         {
             "name": "friendsofsymfony/rest-bundle",
             "version": "1.7.7",
@@ -1067,6 +1220,156 @@
             ],
             "time": "2016-12-21T13:46:54+00:00"
         },
+        {
+            "name": "hwi/oauth-bundle",
+            "version": "0.5.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/hwi/HWIOAuthBundle.git",
+                "reference": "50f4bcbe5c217cfdf0f7f40a174b87199b76d1e1"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/hwi/HWIOAuthBundle/zipball/50f4bcbe5c217cfdf0f7f40a174b87199b76d1e1",
+                "reference": "50f4bcbe5c217cfdf0f7f40a174b87199b76d1e1",
+                "shasum": ""
+            },
+            "require": {
+                "kriswallsmith/buzz": "~0.13",
+                "php": "^5.3.3|^7.0",
+                "symfony/form": "^2.3|^3.0",
+                "symfony/framework-bundle": "^2.3|^3.0",
+                "symfony/options-resolver": "^2.3|^3.0",
+                "symfony/security-bundle": "^2.3|^3.0",
+                "symfony/templating": "^2.7|^3.0",
+                "symfony/yaml": "^2.3|^3.0"
+            },
+            "conflict": {
+                "twig/twig": "<1.12"
+            },
+            "require-dev": {
+                "doctrine/orm": "^2.3",
+                "friendsofphp/php-cs-fixer": "^2.0",
+                "friendsofsymfony/user-bundle": "^1.3|^2.0",
+                "phpunit/phpunit": "^4.8|^5.0",
+                "symfony/phpunit-bridge": "^2.7|^3.0",
+                "symfony/property-access": "^2.3|^3.0",
+                "symfony/stopwatch": "^2.5|^3.0",
+                "symfony/twig-bundle": "^2.3|^3.0",
+                "symfony/validator": "^2.3|^3.0"
+            },
+            "suggest": {
+                "doctrine/doctrine-bundle": "to use Doctrine user provider",
+                "friendsofsymfony/user-bundle": "to connect FOSUB with this bundle",
+                "symfony/property-access": "to use FOSUB integration with this bundle",
+                "symfony/twig-bundle": "to use the Twig hwi_oauth_* functions"
+            },
+            "type": "symfony-bundle",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "0.5-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "HWI\\Bundle\\OAuthBundle\\": ""
+                },
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Contributors",
+                    "homepage": "https://github.com/hwi/HWIOAuthBundle/contributors"
+                },
+                {
+                    "name": "Joseph Bielawski",
+                    "email": "stloyd@gmail.com"
+                },
+                {
+                    "name": "Alexander",
+                    "email": "iam.asm89@gmail.com"
+                },
+                {
+                    "name": "Geoffrey Bachelet",
+                    "email": "geoffrey.bachelet@gmail.com"
+                }
+            ],
+            "description": "Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony2.",
+            "homepage": "http://github.com/hwi/HWIOAuthBundle",
+            "keywords": [
+                "37signals",
+                "Authentication",
+                "Deezer",
+                "EVE Online",
+                "amazon",
+                "asana",
+                "auth0",
+                "azure",
+                "bitbucket",
+                "bitly",
+                "box",
+                "bufferapp",
+                "clever",
+                "dailymotion",
+                "deviantart",
+                "discogs",
+                "disqus",
+                "dropbox",
+                "eventbrite",
+                "facebook",
+                "firewall",
+                "fiware",
+                "flickr",
+                "foursquare",
+                "github",
+                "google",
+                "hubic",
+                "instagram",
+                "jawbone",
+                "jira",
+                "linkedin",
+                "mail.ru",
+                "oauth",
+                "oauth1",
+                "oauth2",
+                "odnoklassniki",
+                "paypal",
+                "qq",
+                "reddit",
+                "runkeeper",
+                "salesforce",
+                "security",
+                "sensio connect",
+                "sina weibo",
+                "slack",
+                "sound cloud",
+                "spotify",
+                "stack exchange",
+                "stereomood",
+                "strava",
+                "toshl",
+                "trakt",
+                "trello",
+                "twitch",
+                "twitter",
+                "vkontakte",
+                "wechat",
+                "windows live",
+                "wordpress",
+                "wunderlist",
+                "xing",
+                "yahoo",
+                "yandex",
+                "youtube"
+            ],
+            "time": "2017-01-08T14:13:58+00:00"
+        },
         {
             "name": "incenteev/composer-parameter-handler",
             "version": "v2.1.2",
@@ -4948,7 +5251,8 @@
     "stability-flags": {
         "voryx/restgeneratorbundle": 20,
         "base-admin": 20,
-        "webservice": 20
+        "webservice": 20,
+        "base-oauth-bundle": 20
     },
     "prefer-stable": false,
     "prefer-lowest": false,