Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"gregwar/captcha-bundle": "^2.4",
"hidehalo/nanoid-php": "^1.1",
"html2text/html2text": "*",
"hwi/oauth-bundle": "2.*",
"incenteev/composer-parameter-handler": "^2.0",
"intervention/image": "^2.4",
"jfcherng/php-levenshtein-distance": "*",
Expand Down
168 changes: 168 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
HWI\Bundle\OAuthBundle\HWIOAuthBundle::class => ['all' => true],
];
9 changes: 9 additions & 0 deletions config/packages/hwi_oauth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# config/packages/hwi_oauth.yaml

hwi_oauth:
resource_owners:
any_name:
type: github
client_id: <client_id>
client_secret: <client_secret>
scope: 'user:email,public_repo'
12 changes: 12 additions & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,23 @@ security:
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true

pattern: ^/
oauth:
resource_owners:
my_github: "/login/check-github"
login_path: /login
use_forward: false
failure_path: /login

oauth_user_provider:
service: my.oauth_aware.user_provider.service

# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/$, roles: PUBLIC_ACCESS }
- { path: ^/login, roles: PUBLIC_ACCESS }
- { path: ^/connect, roles: PUBLIC_ACCESS }
- { path: ^/about, roles: PUBLIC_ACCESS }
- { path: ^/donate, roles: PUBLIC_ACCESS }
- { path: ^/donation, roles: PUBLIC_ACCESS }
Expand Down
15 changes: 15 additions & 0 deletions config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,18 @@ controllers:
legacy:
resource: .
type: legacy

hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.php"
prefix: /connect

hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.php"
prefix: /connect

hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.php"
prefix: /login

github_login:
path: /login/check-github
11 changes: 11 additions & 0 deletions config/routes/hwi_oauth_routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.php"
prefix: /connect

hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.php"
prefix: /connect

hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.php"
prefix: /login
8 changes: 7 additions & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ services:
class: App\Model\MockupProvider\ProfileMockups
tags: [ 'app.mockup_provider' ]

hwi_oauth.user.provider.entity:
class: HWI\Bundle\OAuthBundle\Security\Core\User\EntityUserProvider
arguments:
$class: App\Entity\Member
$properties:
'github': 'github'

App\Form\DataTransformer\LocationRequestToLocationTransformer: ~
App\Form\DataTransformer\DateTransformer: ~

7 changes: 7 additions & 0 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@
class Kernel extends BaseKernel
{
use MicroKernelTrait;

public function registerBundles()
{
$bundles = [
new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
];
}
}
13 changes: 13 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,19 @@
"html2text/html2text": {
"version": "4.3.1"
},
"hwi/oauth-bundle": {
"version": "2.4",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "2.0",
"ref": "20154480d558409ad3eb9de3644817c81fad2268"
},
"files": [
"config/packages/hwi_oauth.yaml",
"config/routes/hwi_oauth_routing.yaml"
]
},
"incenteev/composer-parameter-handler": {
"version": "v2.1.4"
},
Expand Down
3 changes: 3 additions & 0 deletions templates/security/login.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
class="o-button o-button--full">{{ 'indexpageloginsubmit' | trans }}</button>
</div>
</form>
<a href="{{ path('hwi_oauth_service_redirect', {'service': 'github' }) }}">
<span>Login with SSO</span>
</a>
</div>
<div class="card o-card">
<div class="card-body p-2">
Expand Down
Loading