Skip to content

AP595: Stack Pass Request admin form showing Forbidden when not logged in#30

Merged
yzhoubk merged 4 commits intomainfrom
AP-595
Feb 26, 2026
Merged

AP595: Stack Pass Request admin form showing Forbidden when not logged in#30
yzhoubk merged 4 commits intomainfrom
AP-595

Conversation

@yzhoubk
Copy link
Contributor

@yzhoubk yzhoubk commented Feb 24, 2026

Add authenticate before checking user role in StackPass form.

Copy link
Member

@awilfox awilfox left a comment

Choose a reason for hiding this comment

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

This is good, but it's needed at app/controllers/reference_card_forms_controller.rb:87 as well.

@yzhoubk yzhoubk requested a review from anarchivist February 24, 2026 22:20
@yzhoubk
Copy link
Contributor Author

yzhoubk commented Feb 24, 2026

Yes, there maybe other forms.

Copy link
Member

@anarchivist anarchivist left a comment

Choose a reason for hiding this comment

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

I'm in agreement with @awilfox. Does this need to be added to everything that inherits from AuthenticatedFormController that also has before_action :require_admin!? I think that includes ProxyBorrowerAdminController, ReferenceCardFormController, and StackPassAdminController.

In addition, AP-595 also says we should do something about framework/app/views/home/forbidden.html.erb. The text on that page says "Only Library IT developers can access this page." What would be the impact of deleting that view file? Edit: I'll make a separate issue to deal with this - we have a lot of forbidden pages that are fairly inconsistent.

@awilfox
Copy link
Member

awilfox commented Feb 25, 2026

Honestly, I think the entire concept of "require a user and a role" should probably be its own helper; this was a foot-gun I tripped over.

Something like authenticate_with_role!, which takes the role as a parameter, would be good - it would replace the authenticate! call here and internally just perform the logic we're duplicating everywhere.

@anarchivist
Copy link
Member

Maybe we all can chat after standup tomorrow to confirm a path forward?

@yzhoubk
Copy link
Contributor Author

yzhoubk commented Feb 25, 2026

Many other forms use this role check method; only a couple of forms are missing the authentication step. As I mentioned in the ticket, we could consolidate all of these role-check methods into a single place. However, we need to carefully review the roles during the update, as they may be implemented differently across forms. Also, we may also add a CalNet error page, when missing CalNet attributes.

@awilfox
Copy link
Member

awilfox commented Feb 25, 2026

I agree that sounds like the best way forward. Bring the logic into one place, and verify that the roles are being checked correctly on all forms.

Adding a CalNet error page for when attributes are missing sounds like a good idea but should probably be in a separate ticket / MR IMO.

@yzhoubk
Copy link
Contributor Author

yzhoubk commented Feb 25, 2026

Controllers like ProxyBorrowerAdminController and ReferenceCardFormController inherit from AuthenticatedFormController, which already includes before_action :authenticate!, so they do not need to add authenticate before checking role status.

Although some of the other controllers inherit from ApplicationController, they have included before_action :authenticate! on their own.

We only need to add authenticate to ReferenceCardFormController. I don’t see any other forms that need adding it.

Copy link
Member

@anarchivist anarchivist left a comment

Choose a reason for hiding this comment

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

thanks for following up on this. r+; looks good to me.

Copy link
Member

@awilfox awilfox left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you for your thorough investigation of this. r+

@yzhoubk yzhoubk merged commit 12fdb9b into main Feb 26, 2026
5 checks passed
@yzhoubk yzhoubk deleted the AP-595 branch February 26, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants