Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate login and authentication in Back Office to Symfony #35983

Merged
merged 35 commits into from
May 8, 2024

Conversation

jolelievre
Copy link
Contributor

@jolelievre jolelievre commented Apr 22, 2024

Questions Answers
Branch? develop
Description? Migrate login and authentication in Back Office to Symfony
Type? new feature
Category? BO
BC breaks? yes
Deprecations? yes
How to test? CI tests and UI tests green
Manual checks:
- check login to BO
- check logout from BO
- check password reset feature
- check permission are consistent with assigned profile
- check profile edition
UI Tests https://github.com/jolelievre/ga.tests.ui.pr/actions/runs/8921326681
Fixed issue or discussion? Fixes #36002
Related PRs PrestaShop/ga.tests.ui.pr#67 GA UI test tool updated to remove the option about symfony layout that is no forced and the only possibility
Sponsor company ~

@prestonBot
Copy link
Collaborator

Hi, thanks for this contribution!

I found some issues with the Pull Request description:

  • Your pull request does not seem to fix any issue, consider creating one (see note below) and linking it by writing Fixes #1234.

Would you mind having a look at it? This will help us understand how interesting your contribution is, thank you very much!

About linked issues

Please consider opening an issue before submitting a Pull Request:

  • If it's a bug fix, it helps maintainers verify that the bug is effectively due to a defect in the code, and that it hasn't been fixed already.
  • It can help trigger a discussion about the best implementation path before a single line of code is written.
  • It may lead the Core Product team to mark that issue as a priority, further attracting the maintainers' attention.

(Note: this is an automated message, but answering it will reach a real human)

@prestonBot prestonBot added develop Branch Feature Type: New Feature BC break Type: Introduces a backwards-incompatible break labels Apr 22, 2024
@jolelievre jolelievre changed the title Migrate login Migrate login and authentication in Back Office Apr 22, 2024
@jolelievre jolelievre changed the title Migrate login and authentication in Back Office Migrate login and authentication in Back Office to Symfony Apr 22, 2024
@jolelievre jolelievre force-pushed the migrate-login branch 2 times, most recently from 5d4b466 to 46ff748 Compare April 22, 2024 10:26
@jolelievre jolelievre force-pushed the migrate-login branch 21 times, most recently from 9adc35e to 0665025 Compare April 29, 2024 19:14
Copy link
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not seem to reimplement PS_COOKIE_CHECKIP removed. This feature allows to enable/disable checking IP address of the session.

Correct me and remove the block if I am wrong. :-)

@ps-jarvis ps-jarvis added the Waiting for author Status: action required, waiting for author feedback label May 2, 2024
@jolelievre
Copy link
Contributor Author

Does not seem to reimplement PS_COOKIE_CHECKIP removed. This feature allows to enable/disable checking IP address of the session.

Correct me and remove the block if I am wrong. :-)

I didn't know about this one, just like the cron URLs feature I added this in the epic #36001

The present PR is already big enough but it still passes all our autotests, a few left tasks are already identified and will be handled in smaller PRs, if you have other thoughts about missing things feel free to let us know so that we can add them into the epic

I don't think we should block the PR though considering it already handles maybe 90% of the whole login/authorization feature and I can guarantee that all the remaining tasks will be dealt with right after this PR is merged 😉

@prestashop-issue-bot prestashop-issue-bot bot removed the Waiting for author Status: action required, waiting for author feedback label May 2, 2024
Comment on lines +79 to +81
$response = $kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, true);
$response->send();
$kernel->terminate($request, $response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally 👍

@ps-jarvis ps-jarvis added the Waiting for QA Status: action required, waiting for test feedback label May 2, 2024
@Hlavtox
Copy link
Contributor

Hlavtox commented May 2, 2024

@jolelievre No worries, I trust you. Let's merge this so the PR doesn't keep growing. I added the notes to #36001. ;-)

Comment on lines -21 to -30
prestashop.adapter.security.admin:
class: "%AdapterSecurityAdminClass%"
arguments:
- "@prestashop.adapter.legacy.context"
- "@security.token_storage"
- "@prestashop.security.admin.provider"
- "@security.helper"
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

Comment on lines +25 to +26
autowire: true
autoconfigure: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary due to default value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I note to remove it in the next PR 😉

Comment on lines +26 to +27
cookie_key: ThisTokenIsNotSoSecretChangeIt
cookie_iv: ThisTokenIsNotSoSecretChangeIt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could put this in environment variables

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep for now they are default parameters, if we use env variables we can always use the env directive in the parameters, but currently we transform parameters in a PHP file so we can't really enjoy this feature To use this we should do a small refacto to actually use the parameters.yml file

I believe I had to add those default values here because they would make the SF console break when absent at some point, and it's more consistent to have all the required fields in the dist file anyway

Comment on lines +95 to +98
/**
* @ORM\Column(name="email", type="string")
*/
private string $email;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it interesting to add a unique constraint to this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for now, the Doctrine entity is not used in edition (not in the form nor in the CQRS commands), so they would be useless The should be added when we refacto the CQRS commands I guess

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh my bad I misunderstood I thought you were talking about assertions for the entity validation Regarding the unicity of this column you're completely right But it's a change of the DB structure I prefer to handle it in another PR, we also discussed in another comment about removing the theme customizations field, I guess all this could be handled in a dedicated PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 👍

Comment on lines +169 to +193

/**
* @ORM\Column(name="bo_color", type="string", length=32, nullable=true)
*/
private ?string $boColor;

/**
* @ORM\Column(name="bo_theme", type="string", length=32, nullable=true)
*/
private ?string $boTheme;

/**
* @ORM\Column(name="bo_css", type="string", length=64, nullable=true)
*/
private ?string $boCss;

/**
* @ORM\Column(name="bo_width", type="integer", options={"default": 0, "unsigned": true})
*/
private int $boWidth;

/**
* @ORM\Column(name="bo_menu", type="boolean", options={"default": 1})
*/
private bool $boMenu;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I see that I tell myself that it could go to another entity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer used, maybe we can use this opportunity to remove this 💩?

bo_color
bo_width
bo_theme (there is only default)
bo_menu

Ping @kpodemski correct me if I miss something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind, for now I had to leave them in the Doctrine entity or the doctrine command would automatically delete these fields, so I had to sync the content of the entity with the db structure table

We could clean those, but in another PR then

@M0rgan01 M0rgan01 added this to the 9.0.0 milestone May 2, 2024
@paulnoelcholot
Copy link

Hello @jolelievre,

I tested your PR and it's good for me! 🎉

Thanks!

@paulnoelcholot paulnoelcholot added QA ✔️ Status: check done, code approved and removed Waiting for QA Status: action required, waiting for test feedback labels May 7, 2024
@nicosomb nicosomb merged commit 8bad56c into PrestaShop:develop May 8, 2024
39 checks passed
@jolelievre jolelievre deleted the migrate-login branch May 12, 2024 12:35
@kpodemski kpodemski added the Documentation ✔️ Developer documentation is up-to-date label Jul 31, 2024
@gericfo
Copy link

gericfo commented Oct 14, 2024

Hello @jolelievre
Please note that the “Needs autoupgrade PR” label has been automatically added to your Pull Request. This means that the changes made in your PR must also be reported in the Autoupgrade module, responsible for running the update process of PrestaShop stores.
When there's a modification to the db-structure.sql file or if a Doctrine entity has been modified, added, or deleted, it impacts the database structure. Modifying the list of hooks and feature flags has consequences on the update process as well. These changes can affect how the application interacts with the database and how update procedures are handled. It's important to consider these aspects when contributing to ensure a smooth update experience for users.
That's why this contribution should be backported, with another corresponding PR, on the Autoupgrade module's GitHub repository which is available here: link.
Don't forget to add a comment in this current thread with the link to this PR once it has been created.
Thank you.

@gericfo gericfo added the PR Autoupgrade opened ✔️ The associated PR has been opened in the Autoupgrade module repository. label Oct 16, 2024
@gericfo
Copy link

gericfo commented Oct 16, 2024

Related Autoupgrade PR - PrestaShop/autoupgrade#954

@Hlavtox Hlavtox removed Needs autoupgrade PR PR Autoupgrade opened ✔️ The associated PR has been opened in the Autoupgrade module repository. labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC break Type: Introduces a backwards-incompatible break develop Branch Documentation ✔️ Developer documentation is up-to-date Feature Type: New Feature Login Label : access to the back office QA ✔️ Status: check done, code approved Symfony layout
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Migrate login form, logout and handle authorization via Symfony, remove Symfony layout feature flag
10 participants