Skip to content
Merged
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 FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Functional definition for `softspring/user-bundle`.
- invitations
- access history
- Optional OAuth integration points.
- Optional Google Identity Platform login with Google Sign-In and One Tap.
- Doctrine filters for user/admin visibility.
- Mailers, MIME classes, events, and manipulators for user lifecycle actions.
- Console commands for common user and admin operations.
Expand Down
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,76 @@ This package is part of [Armonic](https://softspring.es/en/armonic).

[Armonic Documentation](https://armonic.softspring.es/latest/bundles/user-bundle)

## Optional Google Identity Platform Login

This bundle can render Google Sign-In on the login page and sync users with Google Identity Platform.

The feature is optional.

### 1. Add the optional fields to your user entity

Use the trait and interface only if you enable this feature.

```php
use Softspring\UserBundle\Entity\GoogleIdentityPlatformTrait;
use Softspring\UserBundle\Model\GoogleIdentityPlatformAwareInterface;

class User extends UserModel implements GoogleIdentityPlatformAwareInterface
{
use GoogleIdentityPlatformTrait;
}
```

You will usually also want these existing optional contracts:

- `UserIdentifierEmailInterface`
- `NameSurnameInterface`
- `UserLastLoginInterface`
- `UserAvatarInterface`
- `ConfirmableInterface`

### 2. Import the routes you want to expose

Create a dedicated route import in your application:

```yaml
_sfs_user_google_identity_platform:
resource: '@SfsUserBundle/config/routing/login_google_identity_platform.yaml'
prefix: /auth/google
```

With that prefix, the callback URL will be `/auth/google/callback`.

### 3. Enable the feature in `sfs_user`

```yaml
sfs_user:
login:
google_identity_platform:
enabled: true
client_id: '%env(default::GOOGLE_CLIENT_ID)%'
api_key: '%env(default::IDENTITY_PLATFORM_API_KEY)%'
tenant_id: '%env(default::IDENTITY_PLATFORM_TENANT_ID)%'
success_route: app_home
failure_route: sfs_user_login
```

### 4. Configure Google

The Google OAuth web client must allow:

- your login origin, for example `https://example.test`
- the callback URL from the imported route, for example `https://example.test/auth/google/callback`

The `client_id` must be a Google web client id ending with `.apps.googleusercontent.com`.

### Notes

- The login page only renders the Google widget when the feature is enabled.
- If the routes are not imported, the login page shows a warning instead of rendering a broken button.
- The backend exchange uses `IDENTITY_PLATFORM_API_KEY`.
- `tenant_id` is optional.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"require": {
"php": ">=8.4",
"ext-json": "*",
"doctrine/doctrine-bundle": "^2.10 || ^3.0 || ^4.0",
"doctrine/orm": "^2.10 || ^3.0 || ^4.0",
"doctrine/doctrine-bundle": "^2.17.2 || ^3.0",
"doctrine/orm": "^2.10 || ^3.0",
"softspring/crudl-controller": "^6.0@dev",
"softspring/doctrine-paginator": "^6.0@dev",
"softspring/doctrine-query-filters": "^6.0@dev",
Expand All @@ -33,12 +33,12 @@
"guzzlehttp/promises": "^2.0",
"hwi/oauth-bundle": "^2.0",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^12.5",
"rector/rector": "^2.3",
"softspring/account-bundle": "^6.0@dev",
"softspring/doctrine-templates": "^6.0@dev",
"softspring/mailer-bundle": "^6.0@dev",
"softspring/media-bundle": "^6.0@dev",
"phpunit/phpunit": "^12.5",
"symfony/browser-kit": "^6.4 || ^7.4 || ^8.0",
"symfony/css-selector": "^6.4 || ^7.4 || ^8.0",
"symfony/dom-crawler": "^6.4 || ^7.4 || ^8.0",
Expand All @@ -54,7 +54,7 @@
"softspring/media-bundle": "Stores media files for avatars"
},
"minimum-stability": "dev",
"prefer-stable": false,
"prefer-stable": true,
"autoload": {
"psr-4": {
"Softspring\\UserBundle\\": "src/"
Expand All @@ -80,6 +80,10 @@
}
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"fix": [
"vendor/bin/rector process src tests",
"vendor/bin/php-cs-fixer fix",
Expand All @@ -102,10 +106,6 @@
"test-bc": [
"composer update --no-scripts --ansi --prefer-lowest --prefer-stable",
"@run-tests"
],
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
}
]
}
}
19 changes: 0 additions & 19 deletions config/packages/cache.yaml

This file was deleted.

50 changes: 0 additions & 50 deletions config/packages/doctrine.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions config/packages/framework.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions config/packages/mailer.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions config/packages/routing.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions config/packages/security.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions config/packages/translation.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions config/packages/twig.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions config/packages/validator.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions config/routing/login_google_identity_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sfs_user_login_google_identity_platform:
path: /one-tap
controller: Softspring\UserBundle\Controller\GoogleIdentityPlatformLoginController::authenticate
methods: [POST]

sfs_user_login_google_identity_platform_callback:
path: /callback
controller: Softspring\UserBundle\Controller\GoogleIdentityPlatformLoginController::authenticate
methods: [POST]
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
$resetTokenTTL: '%sfs_user.reset_password.token_ttl%'
$oauthServices: '%sfs_user.oauth.services%'
$targetPathParameter: '%sfs_user.login.target_path_parameter%'
$googleIdentityPlatformConfig: '%sfs_user.login.google_identity_platform%'

Softspring\UserBundle\Command\CreateUserCommand: ~
Softspring\UserBundle\Command\PromoteUserCommand: ~
Expand Down
17 changes: 17 additions & 0 deletions config/services/google_identity_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false
bind:
$googleIdentityPlatformConfig: '%sfs_user.login.google_identity_platform%'

Softspring\UserBundle\Controller\GoogleIdentityPlatformLoginController:
public: true

Softspring\UserBundle\GoogleIdentityPlatform\IdentityPlatformGoogleAuthenticator:
arguments:
$apiKey: '%sfs_user.login.google_identity_platform.api_key%'
$tenantId: '%sfs_user.login.google_identity_platform.tenant_id%'

Softspring\UserBundle\GoogleIdentityPlatform\IdentityPlatformUserSynchronizer: ~
10 changes: 1 addition & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@
<env name="APP_SECRET" value="f56343225038b8f701f54cd3d5bfcde2"/>
<!-- ###- symfony/framework-bundle ### -->

<!-- ###+ doctrine/doctrine-bundle ### -->
<!-- Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url -->
<!-- IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml -->
<!-- -->
<!-- DATABASE_URL="sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db" -->
<!-- DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4" -->
<!-- DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" -->
<env name="DATABASE_URL" value="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&amp;charset=utf8"/>
<!-- ###- doctrine/doctrine-bundle ### -->
<env name="DATABASE_URL" value="sqlite:////tmp/com.github.softspring.userbundle/tests/var/test/test_database.sqlite"/>
</php>

<!-- <extensions>-->
Expand Down
Empty file removed src/Controller/.gitignore
Empty file.
Loading
Loading