Skip to content

Commit 8a453ae

Browse files
committed
initial openID
1 parent fcebc43 commit 8a453ae

File tree

16 files changed

+587
-159
lines changed

16 files changed

+587
-159
lines changed

app/AppKernel.php

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,41 @@
55

66
class AppKernel extends Kernel
77
{
8-
public function registerBundles()
9-
{
10-
$bundles = array(
11-
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
12-
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
13-
new Symfony\Bundle\TwigBundle\TwigBundle(),
14-
new Symfony\Bundle\MonologBundle\MonologBundle(),
15-
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
16-
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
17-
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
18-
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
19-
new JMS\AopBundle\JMSAopBundle(),
20-
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
21-
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
22-
new Google\OauthBundle\GoogleOauthBundle(),
23-
new Knp\Bundle\OAuthBundle\KnpOAuthBundle(),
24-
new Sensio\Bundle\BuzzBundle\SensioBuzzBundle(),
25-
);
268

27-
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
28-
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
29-
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
30-
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
31-
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
32-
}
9+
public function registerBundles()
10+
{
11+
$bundles = array(
12+
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
13+
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
14+
new Symfony\Bundle\TwigBundle\TwigBundle(),
15+
new Symfony\Bundle\MonologBundle\MonologBundle(),
16+
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
17+
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
18+
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
19+
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
20+
new JMS\AopBundle\JMSAopBundle(),
21+
new JMS\DiExtraBundle\JMSDiExtraBundle( $this ),
22+
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
23+
new Google\OauthBundle\GoogleOauthBundle(),
24+
new Knp\Bundle\OAuthBundle\KnpOAuthBundle(),
25+
new Sensio\Bundle\BuzzBundle\SensioBuzzBundle(),
26+
new Fp\OpenIdBundle\FpOpenIdBundle(),
27+
);
3328

34-
return $bundles;
35-
}
29+
if (in_array( $this->getEnvironment(), array('dev', 'test') ))
30+
{
31+
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
32+
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
33+
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
34+
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
35+
}
36+
37+
return $bundles;
38+
}
39+
40+
public function registerContainerConfiguration(LoaderInterface $loader)
41+
{
42+
$loader->load( __DIR__ . '/config/config_' . $this->getEnvironment() . '.yml' );
43+
}
3644

37-
public function registerContainerConfiguration(LoaderInterface $loader)
38-
{
39-
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
40-
}
4145
}

app/config/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
imports:
22
- { resource: parameters.yml }
33
- { resource: security.yml }
4+
# - { resource: @GoogleOauthBundle/Resources/config/services.yml }
45

56
framework:
67
#esi: ~
@@ -56,3 +57,7 @@ swiftmailer:
5657
username: %mailer_user%
5758
password: %mailer_password%
5859
spool: { type: memory }
60+
61+
fp_open_id:
62+
db_driver: orm
63+
identity_class: Google\OauthBundle\Entity\OpenIdIdentity

app/config/routing.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ GoogleOauthBundle:
33
type: annotation
44
prefix: /
55

6+
fp_openid_security:
7+
resource: "@FpOpenIdBundle/Resources/config/routing/security.xml"
8+
69
# Internal routing configuration to handle ESI
710
#_internal:
811
# resource: "@FrameworkBundle/Resources/config/routing/internal.xml"

app/config/security.yml

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,88 @@ jms_security_extra:
44

55
security:
66
encoders:
7-
Symfony\Component\Security\Core\User\User: plaintext
7+
# Symfony\Component\Security\Core\User\User: plaintext
8+
Google\OauthBundle\Entity\User: md5
89

910
role_hierarchy:
1011
ROLE_ADMIN: ROLE_USER
1112
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
1213

1314
providers:
14-
main:
15-
oauth_entity:
16-
class: Google\OauthBundle\Entity:User
17-
property: name
15+
# secured_area:
16+
# oauth_entity:
17+
# class: GoogleOauthBundle:User
18+
# property: name
19+
administrators:
20+
entity: {class: GoogleOauthBundle:User, property: username}
21+
openid_user_manager:
22+
id: google.oauth.openid_user_manager
1823

19-
in_memory:
20-
memory:
21-
users:
22-
user: { password: userpass, roles: [ 'ROLE_USER' ] }
23-
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
24+
# in_memory:
25+
# memory:
26+
# users:
27+
# user: { password: userpass, roles: [ 'ROLE_USER' ] }
28+
# admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
2429

2530
firewalls:
26-
dev:
27-
pattern: ^/(_(profiler|wdt)|css|images|js)/
28-
security: false
31+
main:
32+
pattern: ^/
33+
logout: true
34+
anonymous: true
35+
36+
fp_openid:
37+
create_user_if_not_exists: true
38+
required_attributes: [namePerson/friendly,contact/email,namePerson,birthDate,pref/language,contact/country/home,person/gender]
39+
optional_attributes: []
40+
# options come with abstract listener
41+
check_path: /login_check
42+
default_target_path: /hello/wtf
43+
provider: openid_user_manager
2944

30-
login:
31-
pattern: ^/demo/secured/login$
32-
security: false
3345

34-
secured_area:
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-
49-
form_login:
50-
check_path: /demo/secured/login_check
51-
login_path: /demo/secured/login
52-
logout:
53-
path: /secured/logout
54-
target: /
46+
47+
# dev:
48+
# pattern: ^/(_(profiler|wdt)|css|images|js)/
49+
# security: false
50+
#
51+
# login:
52+
# pattern: ^/demo/secured/login$
53+
# security: false
54+
#
55+
# secured_area:
56+
## pattern: ^/secured/
57+
## oauth:
58+
## oauth_provider: google
59+
## authorization_url: https://accounts.google.com/o/oauth2/auth
60+
## access_token_url: https://accounts.google.com/o/oauth2/token
61+
## infos_url: https://www.googleapis.com/oauth2/v1/userinfo
62+
## username_path: name
63+
## client_id: 66772032914.apps.googleusercontent.com
64+
## secret: 6ITw8qAL--zt34nzAPodEAgW
65+
## scope: userinfo.profile
66+
## check_path: /secured/login_check
67+
## login_path: /secured/login
68+
## failure_path: /
69+
#
70+
# pattern: ^/demo/secured/
71+
#
72+
# form_login:
73+
# check_path: /demo/secured/login_check
74+
# login_path: /demo/secured/login
75+
# logout:
76+
# path: /secured/logout
77+
# target: /
5578
#anonymous: ~
5679
#http_basic:
5780
# realm: "Secured Demo Area"
5881

5982
access_control:
83+
- { path: ^/login_openid$, role: IS_AUTHENTICATED_ANONYMOUSLY }
84+
- { path: ^/hello, role: IS_AUTHENTICATED_OPENID }
85+
6086
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
6187
#- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
88+
89+
#fp_open_id:
90+
# db_driver: orm
91+
# identity_class: Google\OauthBundle\Entity\OpenIdIdentity

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"jms/di-extra-bundle": "1.0.*",
2121
"doctrine/data-fixtures": "*",
2222
"zend/gdata": "*",
23-
"knplabs/knp-oauth-bundle": "*"
23+
"knplabs/knp-oauth-bundle": "*",
24+
"fp/openid-bundle": "dev-master"
2425
},
2526
"scripts": {
2627
"post-install-cmd": [

0 commit comments

Comments
 (0)