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

Refactoring pundit for authentication #16133

Merged
merged 13 commits into from
May 22, 2024

Conversation

hennevogel
Copy link
Member

@hennevogel hennevogel commented May 14, 2024

In #10083 we extended our pundit ApplicationPolicy with an option to ensure that someone is logged in. We then started to bake this into controllers. I think the analysis of #10083 is wrong, Pundit is for authorization a.k.a. who can do what. require_login is for ensuring someone is authenticated a.k.a User.session is set.

It should have been clear that this isn't the best idea by the amount of custom code we had to add to pundit policies and controllers. Let's roll this back.

Closes #10083

@hennevogel hennevogel marked this pull request as draft May 14, 2024 13:36
@github-actions github-actions bot added the Frontend Things related to the OBS RoR app label May 14, 2024
@hennevogel hennevogel marked this pull request as ready for review May 14, 2024 16:13
@hennevogel hennevogel force-pushed the refactoring/require_login branch 4 times, most recently from d6fcd97 to b0ffbe7 Compare May 14, 2024 21:00
@github-actions github-actions bot added the Documentation 📖 Things regarding our documentation label May 14, 2024
@hennevogel hennevogel force-pushed the refactoring/require_login branch 6 times, most recently from ddd2cea to 3fe90e3 Compare May 15, 2024 15:31
@hennevogel
Copy link
Member Author

I'm not going to touch the codeclimate complaint in check_creator. I have no idea what this fixes and what the logic is supposed to be. I just moved code...

Use the standard require_login before action instead (which is
running by default in the API...)

KISS
Use the standard require_login before action.

Also, drop the `params['default_form']` handling, it isn't used anywhere.
Probably was before the admin part got moved to `Webui::SubscriptionsController`?
It was only used to require User.session for this route.
Require login for /my/patchinfos via standard means. KISS
It was only used require an authenticated User.session.
Require login for /my/tasks via standard means. KISS
Instead follow the other examples in ReportPolicy: You can not report things
you created.
Use the standard require_login before action. KISS.
Use the standard require_login before action. KISS.
Use the standard require_login before action. KISS.

Also: Use policy_scope to limit what people can see.
No need to duplicate the policy. It already lead to deviation for update?
and the "stub" code allowing everything is a nasty trap.
There are no notifications anymore with subscriber_type 'Group' since we create
a notification for every group member instead.
- spec if out completely in rspec, drop minitest tests
- update was not exposed in the routes
- XML consumed was not validated correctly
- no error handling for create/update
@hennevogel hennevogel merged commit 456d452 into openSUSE:master May 22, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation 📖 Things regarding our documentation Frontend Things related to the OBS RoR app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace require_login controller filters with Pundit policies
2 participants