Skip to content

Commit fcebc43

Browse files
committed
knpOauth
1 parent ffdfa52 commit fcebc43

File tree

9 files changed

+181
-43
lines changed

9 files changed

+181
-43
lines changed

app/AppKernel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public function registerBundles()
2020
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
2121
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
2222
new Google\OauthBundle\GoogleOauthBundle(),
23+
new Knp\Bundle\OAuthBundle\KnpOAuthBundle(),
24+
new Sensio\Bundle\BuzzBundle\SensioBuzzBundle(),
2325
);
2426

2527
if (in_array($this->getEnvironment(), array('dev', 'test'))) {

app/config/security.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ security:
1111
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
1212

1313
providers:
14+
main:
15+
oauth_entity:
16+
class: Google\OauthBundle\Entity:User
17+
property: name
18+
1419
in_memory:
1520
memory:
1621
users:
@@ -27,13 +32,26 @@ security:
2732
security: false
2833

2934
secured_area:
30-
pattern: ^/demo/secured/
35+
pattern: ^/secured/
36+
oauth:
37+
oauth_provider: google
38+
authorization_url: ~
39+
access_token_url: ~
40+
infos_url: ~
41+
username_path: user.login
42+
client_id: 66772032914.apps.googleusercontent.com
43+
secret: 6ITw8qAL--zt34nzAPodEAgW
44+
scope: userinfo.profile
45+
check_path: /secured/login_check
46+
login_path: /secured/login
47+
failure_path: /
48+
3149
form_login:
3250
check_path: /demo/secured/login_check
3351
login_path: /demo/secured/login
3452
logout:
35-
path: /demo/secured/logout
36-
target: /demo/
53+
path: /secured/logout
54+
target: /
3755
#anonymous: ~
3856
#http_basic:
3957
# realm: "Secured Demo Area"

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"jms/security-extra-bundle": "1.1.*",
2020
"jms/di-extra-bundle": "1.0.*",
2121
"doctrine/data-fixtures": "*",
22-
"zend/gdata": "*"
22+
"zend/gdata": "*",
23+
"knplabs/knp-oauth-bundle": "*"
2324
},
2425
"scripts": {
2526
"post-install-cmd": [

composer.lock

Lines changed: 32 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nbproject/project.properties

Lines changed: 0 additions & 7 deletions
This file was deleted.

nbproject/project.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Google/OauthBundle/Controller/DefaultController.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
class DefaultController extends Controller
1010
{
1111

12-
const domain = 'testGoogle.au';
12+
const domain = 'teamlogin.com';
1313

14-
protected $email = 'chen.li@teamlogin.com';
15-
protected $password = '123456qqq';
14+
protected $email = 'gotcha@teamlogin.com';
15+
protected $password = '12345694';
1616
protected $username = 'cp3';
1717
protected $givenname = 'nima';
1818
protected $familyname = 'heiA';
@@ -34,8 +34,17 @@ public function indexAction($name)
3434
// $proxiedHttpClient = new \Zend_Http_Client( 'http://www.google.com:443', $config );
3535

3636
$client = \Zend_Gdata_ClientLogin::getHttpClient( $this->email, $this->password, \Zend_Gdata_Gapps::AUTH_SERVICE_NAME );
37-
// $service = new \Zend_Gdata_Gapps( $client, self::domain );
37+
$gdata = new \Zend_Gdata_Gapps( $client, self::domain );
3838
// $service->createUser( $this->username, $this->givenname, $this->familyname, $this->password_c, $passwordHashFunction = null, $quota = null );
39+
$users = $gdata->getUserFeed();
40+
41+
foreach ($users as $user)
42+
{
43+
echo " * " . $user->login->username . ' (' . $user->name->givenName .
44+
' ' . $user->name->familyName . ")\n";
45+
}
46+
47+
var_dump($gdata->isOwner('[email protected]', 'hr'));
3948

4049
return array('name' => $name);
4150
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
namespace Google\OauthBundle\Entity;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Entity
9+
* @ORM\Table(name="user")
10+
*/
11+
class User
12+
{
13+
14+
/**
15+
* @ORM\Id
16+
* @ORM\Column(type="integer")
17+
* @ORM\GeneratedValue(strategy="AUTO")
18+
*/
19+
protected $id;
20+
21+
/** @ORM\Column(type="string") * */
22+
protected $name;
23+
24+
/** @ORM\Column(type="string") * */
25+
protected $pwd;
26+
27+
//put your code here
28+
29+
/**
30+
* Get id
31+
*
32+
* @return integer
33+
*/
34+
public function getId()
35+
{
36+
return $this->id;
37+
}
38+
39+
/**
40+
* Set name
41+
*
42+
* @param string $name
43+
* @return User
44+
*/
45+
public function setName($name)
46+
{
47+
$this->name = $name;
48+
return $this;
49+
}
50+
51+
/**
52+
* Get name
53+
*
54+
* @return string
55+
*/
56+
public function getName()
57+
{
58+
return $this->name;
59+
}
60+
61+
/**
62+
* Set pwd
63+
*
64+
* @param string $pwd
65+
* @return User
66+
*/
67+
public function setPwd($pwd)
68+
{
69+
$this->pwd = $pwd;
70+
return $this;
71+
}
72+
73+
/**
74+
* Get pwd
75+
*
76+
* @return string
77+
*/
78+
public function getPwd()
79+
{
80+
return $this->pwd;
81+
}
82+
83+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Google\OauthBundle\Entity;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Entity
9+
* @ORM\Table(name="user")
10+
*/
11+
class User
12+
{
13+
14+
/**
15+
* @ORM\Id
16+
* @ORM\Column(type="integer")
17+
* @ORM\GeneratedValue(strategy="AUTO")
18+
*/
19+
protected $id;
20+
/** @ORM\Column(type="string") **/
21+
protected $name;
22+
/** @ORM\Column(type="string") **/
23+
protected $pwd;
24+
25+
//put your code here
26+
}
27+
28+
?>

0 commit comments

Comments
 (0)