Fix #5675: Feature Request for Private Community Boards - #6478
Conversation
|
You can probably just modify |
|
Thanks for the suggestion: indeed using policies is much cleaner (no need for "skip" override). I updated PR with the following:
I ran the entire test suite, got 89 failed tests, all are related to external sites (extractors tests). I guess this is expected. |
Implement two config settings: - force_authenticated: only authenticated users can access most pages (except ones related to login, password reset, 2fa verify etc.) - signups_restricted_to_admin: turn off the ability to self-register. Only admin (or higher) can register users. These settings can be used individually, or together.
|
Update: During my tests I've found some pages that were not affected by the The list of policies I updated:
Maybe I don't understand something there, and those methods were redefined for a reason? Any advice is appreciated. |
|
Look around the policies for them. There's redundant |
|
Yes, that's what I did after noticing the first such URL - I grepped for the I updated the pull request with the newest changes. |
|
Before going through the pull: the main problem with merging something like this is that we basically have to support it in perpetuity. This is the kind of feature that is very easily breakable by new endpoint addition, it's not a matter of when but if, because we are not going to be focused on mantaining features that the main site will never use. Also, you're trying to introduce two pretty big features at once in this pull, and neither will ever be used by the main site. These two features work in tandem, so why are they separate? And the workflow for new user creation does not make much sense to me. Are you expecting admins to manually create users and then give account passwords away? I don't think that's acceptable. If you want a completely locked system, it would probably make more sense to restrict vision to verified users (members) rather than registered users. Basically, all new accounts start as restricted, and the only way to view stuff is be promoted to member by an admin. That way you avoid direct password handling. But again, that's something that you'd have in your own fork, we're not really interested in having that kind of logic in the main repo because it would just be a feature we'd have to mantain forever despite never using it. |
Implemented two config knobs:
Both of these knobs are false by default, so the original behavior is preserved.
How it is done:
The application controller gets a new gate
force_authenticatedthat is executed for every page. With theforce_authenticatedconfig knob set to false, it is skipped.To bypass the restriction for certain pages (health checks, password reset, 2fa verification),
skip_force_authenticatedis introduced and used in those views.UserPolicy is adjusted to either allow the anonymous users to sign up, or limit it to admin users, depending on the
signups_restricted_to_adminconfig value.The templates mentioning Sign Up link are edited not to show it when
signups_restricted_to_adminis set.I am open to feedback and suggestions.
Disclaimer: I had not worked with RoR before (I occasionally write in ruby, though), so I leveraged an LLM to produce this. I have read and understood every line in the change though.
Upd: if this feature feels too big to merge (I understand that Danbooru itself has no plans to use it), then reverting the template changes might also be an option.