diff --git a/softspring/user-bundle/5.2/config/packages/security.yaml.dist b/softspring/user-bundle/5.2/config/packages/security.yaml.dist new file mode 100644 index 00000000..e06e7503 --- /dev/null +++ b/softspring/user-bundle/5.2/config/packages/security.yaml.dist @@ -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 diff --git a/softspring/user-bundle/5.2/config/packages/sfs_admin_menu_users.yaml b/softspring/user-bundle/5.2/config/packages/sfs_admin_menu_users.yaml new file mode 100644 index 00000000..9defd1a4 --- /dev/null +++ b/softspring/user-bundle/5.2/config/packages/sfs_admin_menu_users.yaml @@ -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' diff --git a/softspring/user-bundle/5.2/config/packages/sfs_user.yaml b/softspring/user-bundle/5.2/config/packages/sfs_user.yaml new file mode 100644 index 00000000..45662936 --- /dev/null +++ b/softspring/user-bundle/5.2/config/packages/sfs_user.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: '@SfsUserBundle/config/security/admin_role_hierarchy.yaml' } diff --git a/softspring/user-bundle/5.2/config/routes/sfs_user.yaml b/softspring/user-bundle/5.2/config/routes/sfs_user.yaml new file mode 100644 index 00000000..086eab0e --- /dev/null +++ b/softspring/user-bundle/5.2/config/routes/sfs_user.yaml @@ -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" diff --git a/softspring/user-bundle/5.2/config/routes/sfs_user_admin.yaml b/softspring/user-bundle/5.2/config/routes/sfs_user_admin.yaml new file mode 100644 index 00000000..32e55c7d --- /dev/null +++ b/softspring/user-bundle/5.2/config/routes/sfs_user_admin.yaml @@ -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" diff --git a/softspring/user-bundle/5.2/manifest.json b/softspring/user-bundle/5.2/manifest.json new file mode 100644 index 00000000..e5060a5f --- /dev/null +++ b/softspring/user-bundle/5.2/manifest.json @@ -0,0 +1,10 @@ +{ + "bundles": { + "Softspring\\UserBundle\\SfsUserBundle": ["all"] + }, + "copy-from-recipe": { + "config/": "config/", + "src/": "src/", + "translations/": "translations/" + } +} diff --git a/softspring/user-bundle/5.2/post-install.txt b/softspring/user-bundle/5.2/post-install.txt new file mode 100644 index 00000000..0a9221be --- /dev/null +++ b/softspring/user-bundle/5.2/post-install.txt @@ -0,0 +1,15 @@ + * The 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 diff --git a/softspring/user-bundle/5.2/src/Entity/User.php b/softspring/user-bundle/5.2/src/Entity/User.php new file mode 100644 index 00000000..05ce6b41 --- /dev/null +++ b/softspring/user-bundle/5.2/src/Entity/User.php @@ -0,0 +1,72 @@ + 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(); + } +} diff --git a/softspring/user-bundle/5.2/translations/sfs_components.en.yaml b/softspring/user-bundle/5.2/translations/sfs_components.en.yaml new file mode 100644 index 00000000..360790ea --- /dev/null +++ b/softspring/user-bundle/5.2/translations/sfs_components.en.yaml @@ -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"