-
-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add softspring user-bundle * Fix softspring user-bundle with blank lines * Add postinstall
- Loading branch information
Showing
9 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
softspring/user-bundle/5.2/config/packages/security.yaml.dist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
security: | ||
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords | ||
password_hashers: | ||
Symfony\\Component\\Security\\Core\\User\\PasswordAuthenticatedUserInterface: 'auto' | ||
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider | ||
providers: | ||
sfs_user: | ||
id: sfs_user.user_provider | ||
|
||
access_decision_manager: | ||
strategy: unanimous | ||
allow_if_all_abstain: false | ||
|
||
role_hierarchy: | ||
ROLE_ADMIN: | ||
- ROLE_ADMIN_USERS_RW | ||
#- ROLE_ADMIN_INVITATION_RO | ||
#- ROLE_ALLOWED_TO_SWITCH | ||
- ROLE_ADMIN_ADMINISTRATORS_RW | ||
ROLE_SUPER_ADMIN: | ||
- ROLE_ADMIN | ||
- ROLE_ADMIN_ADMINISTRATORS_PROMOTE_SUPER | ||
- ROLE_ADMIN_ADMINISTRATORS_DEMOTE_SUPER | ||
|
||
firewalls: | ||
dev: | ||
pattern: ^/(_(profiler|wdt)|css|images|js)/ | ||
security: false | ||
|
||
main: | ||
pattern: ^/(admin|app)/ | ||
lazy: true | ||
provider: sfs_user | ||
form_login: | ||
provider: sfs_user | ||
login_path: sfs_user_login | ||
check_path: sfs_user_login_check | ||
|
||
# login_throttling: | ||
# max_attempts: 5 | ||
# interval: '1 minute' | ||
|
||
# remember_me: | ||
# secret: \"%env(APP_SECRET)%\" | ||
# lifetime: 2592000 # 1 month | ||
# secure: true | ||
# httponly: true | ||
# always_remember_me: false | ||
|
||
logout: | ||
path: sfs_user_logout | ||
|
||
# switch_user: | ||
# role: ROLE_ALLOWED_TO_SWITCH | ||
# parameter: _switch_user | ||
|
||
access_control: | ||
- { path: ^/app/login, roles: PUBLIC_ACCESS } | ||
# - { path: ^/app/invitation, roles: PUBLIC_ACCESS } | ||
# - { path: ^/app/register, roles: PUBLIC_ACCESS } | ||
- { path: ^/app/reset-password, roles: PUBLIC_ACCESS } | ||
- { path: ^/admin, roles: ROLE_ADMIN } | ||
|
||
when@test: | ||
security: | ||
password_hashers: | ||
# By default, password hashers are resource intensive and take time. This is | ||
# important to generate secure password hashes. In tests however, secure hashes | ||
# are not important, waste resources and increase test times. The following | ||
# reduces the work factor to the lowest possible values. | ||
Symfony\\Component\\Security\\Core\\User\\PasswordAuthenticatedUserInterface: | ||
algorithm: auto | ||
cost: 4 # Lowest possible value for bcrypt | ||
time_cost: 3 # Lowest possible value for argon | ||
memory_cost: 10 # Lowest possible value for argon |
29 changes: 29 additions & 0 deletions
29
softspring/user-bundle/5.2/config/packages/sfs_admin_menu_users.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
twig: | ||
globals: | ||
admin_menu: | ||
users: | ||
translation_key: 'sidebar.menu.users.title' | ||
users: | ||
translation_key: 'sidebar.menu.users.users' | ||
route: 'sfs_user_admin_users_list' | ||
role: PERMISSION_SFS_USER_ADMIN_USERS_LIST | ||
active_expression: 'sfs_user_admin_users_' | ||
icon: 'bi bi-people' | ||
administrators: | ||
translation_key: 'sidebar.menu.users.administrators' | ||
route: 'sfs_user_admin_administrators_list' | ||
role: PERMISSION_SFS_USER_ADMIN_ADMINISTRATORS_LIST | ||
active_expression: 'sfs_user_admin_administrators_' | ||
icon: 'bi bi-people-fill' | ||
# history: | ||
# translation_key: 'sidebar.menu.users.access_history' | ||
# route: 'sfs_user_admin_access_history_list' | ||
# role: ROLE_ADMIN_ACCESS_HISTORY_LIST | ||
# active_expression: 'sfs_user_admin_access_history_' | ||
# icon: 'bi bi-person-lines-fill' | ||
# invitations: | ||
# translation_key: 'sidebar.menu.users.invitations' | ||
# route: 'sfs_user_admin_invitations_list' | ||
# role: ROLE_ADMIN_INVITATIONS_LIST | ||
# active_expression: 'sfs_user_admin_invitations_' | ||
# icon: 'bi bi-person-plus' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
imports: | ||
- { resource: '@SfsUserBundle/config/security/admin_role_hierarchy.yaml' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
_sfs_login: | ||
resource: '@SfsUserBundle/config/routing/login.yaml' | ||
|
||
#_sfs_invitation: | ||
# resource: '@SfsUserBundle/config/routing/invitation.yaml' | ||
# prefix: "/invitation" | ||
|
||
_sfs_reset_password: | ||
resource: '@SfsUserBundle/config/routing/reset_password.yaml' | ||
prefix: "/reset-password" | ||
|
||
_sfs_change_password: | ||
resource: '@SfsUserBundle/config/routing/change_password.yaml' | ||
prefix: "/user/change-password" | ||
|
||
#_sfs_register: | ||
# resource: '@SfsUserBundle/config/routing/register.yaml' | ||
# prefix: "/register" | ||
|
||
_sfs_preferences: | ||
resource: '@SfsUserBundle/config/routing/preferences.yaml' | ||
prefix: "/user/preferences" |
15 changes: 15 additions & 0 deletions
15
softspring/user-bundle/5.2/config/routes/sfs_user_admin.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
_sfs_user_admin: | ||
resource: "@SfsUserBundle/config/routing/admin_users.yaml" | ||
prefix: "/admin/user" | ||
|
||
_sfs_user_admins: | ||
resource: "@SfsUserBundle/config/routing/admin_administrators.yaml" | ||
prefix: "/admin/admins" | ||
|
||
_sfs_user_invitations: | ||
resource: "@SfsUserBundle/config/routing/admin_invitations.yaml" | ||
prefix: "/admin/invitations" | ||
|
||
#_sfs_user_history: | ||
# resource: "@SfsUserBundle/config/routing/admin_access_history.yaml" | ||
# prefix: "/admin/access-history" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"bundles": { | ||
"Softspring\\UserBundle\\SfsUserBundle": ["all"] | ||
}, | ||
"copy-from-recipe": { | ||
"config/": "config/", | ||
"src/": "src/", | ||
"translations/": "translations/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
* The <fg=green>SfsUserBundle</> is ready to use. | ||
* Now you need to make some manually changes: | ||
|
||
Add the config/packages/security.yaml.dist to your yaml file | ||
mv config/packages/security.yaml.dist config/packages/security.yaml | ||
|
||
Run doctrine migrations | ||
php bin/console doctrine:migrations:diff --namespace=\"DoctrineMigrations\" | ||
php bin/console doctrine:migrations:migrate -n | ||
|
||
Create a user | ||
php bin/console sfs:user:create username email password | ||
|
||
Promote the user to admin if you want | ||
php bin/console sfs:user:promote username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace App\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Softspring\UserBundle\Entity\ConfirmableTrait; | ||
use Softspring\UserBundle\Entity\NameSurnameTrait; | ||
use Softspring\UserBundle\Entity\PasswordRequestTrait; | ||
use Softspring\UserBundle\Entity\RolesAdminTrait; | ||
use Softspring\UserBundle\Entity\UserHasLocalePreferenceTrait; | ||
use Softspring\UserBundle\Entity\UserIdentifierEmailTrait; | ||
use Softspring\UserBundle\Entity\UserLastLoginTrait; | ||
use Softspring\UserBundle\Entity\UserPasswordTrait; | ||
use Softspring\UserBundle\Model\ConfirmableInterface; | ||
use Softspring\UserBundle\Model\NameSurnameInterface; | ||
use Softspring\UserBundle\Model\PasswordRequestInterface; | ||
use Softspring\UserBundle\Model\RolesAdminInterface; | ||
use Softspring\UserBundle\Model\User as UserModel; | ||
use Softspring\UserBundle\Model\UserAvatarInterface; | ||
use Softspring\UserBundle\Model\UserAvatarTrait; | ||
use Softspring\UserBundle\Model\UserHasLocalePreferenceInterface; | ||
use Softspring\UserBundle\Model\UserIdentifierEmailInterface; | ||
use Softspring\UserBundle\Model\UserLastLoginInterface; | ||
use Softspring\UserBundle\Model\UserPasswordInterface; | ||
|
||
/** | ||
* @ORM\Entity() | ||
* @ORM\HasLifecycleCallbacks() | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\HasLifecycleCallbacks] | ||
class User extends UserModel implements NameSurnameInterface, UserPasswordInterface, PasswordRequestInterface, UserIdentifierEmailInterface, UserAvatarInterface, ConfirmableInterface, RolesAdminInterface, UserLastLoginInterface, UserHasLocalePreferenceInterface | ||
{ | ||
use UserIdentifierEmailTrait; | ||
use NameSurnameTrait; | ||
use UserPasswordTrait; | ||
use PasswordRequestTrait; | ||
use UserAvatarTrait; | ||
use ConfirmableTrait; | ||
use RolesAdminTrait; | ||
use UserLastLoginTrait; | ||
use UserHasLocalePreferenceTrait; | ||
|
||
/** | ||
* @ORM\Id | ||
* @ORM\Column(length=13, options={"fixed": true}) | ||
* @ORM\GeneratedValue(strategy="NONE") | ||
*/ | ||
#[ORM\Id] | ||
#[ORM\Column(length: 13, options: ['fixed' => true])] | ||
#[ORM\GeneratedValue(strategy: 'NONE')] | ||
protected ?string $id = null; | ||
|
||
public function getId(): ?string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @ORM\PrePersist() | ||
*/ | ||
#[ORM\PrePersist] | ||
public function _generateId(): void | ||
{ | ||
$this->id = uniqid(); | ||
} | ||
|
||
public function getDisplayName(): string | ||
{ | ||
return $this->getName().' '.$this->getSurname(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
softspring/user-bundle/5.2/translations/sfs_components.en.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sidebar.menu.users.title: "Users" | ||
sidebar.menu.users.users: "Users" | ||
sidebar.menu.users.administrators: "Administrators" | ||
sidebar.menu.users.invitations: "Invitations" | ||
sidebar.menu.mails.title: "Emails" |