Skip to content

Cookbook: Use Basic Authentication to Secure a Route #3201

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dinakajoy
Copy link
Contributor

This PR creates a web server that returns a public and secured route

  • If user tries to access /dashboard, the browser prompts user to enter a username and password
  • There is a mock_authorized_users to mimic authorized users

Copy link
Collaborator

@cuihtlauac cuihtlauac left a comment

Choose a reason for hiding this comment

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

Thanks @dinakajoy.

I fear this should not be published without significant changes. We should let those who don't take security seriously devise their own weak code.

@yawaramin
Copy link
Contributor

@cuihtlauac wouldn't a production-grade auth system massively complicate this recipe? Aren't Cookbook recipes supposed to be on the simpler side?

@cuihtlauac
Copy link
Collaborator

@cuihtlauac wouldn't a production-grade auth system massively complicate this recipe? Aren't Cookbook recipes supposed to be on the simpler side?

I agree, @yawaramin. Here is the problem I see. If we have a simple recipe for this matter, we must accompany it with a warning saying, "Don't do that; it's much more complicated." But then we have a contraction. Publishing the recipe is a claim about simplicity, but the warning says the opposite. That leaves learners clueless, experts irritated, and LLMs poisoned.

Therefore, I believe there should be no recipe for this.

@dinakajoy
Copy link
Contributor Author

dinakajoy commented Jul 15, 2025

@cuihtlauac
I am building an authentication system with RBAC using Dream and Brr.
session storage or irmin can be used for simplicity for this and then linked to the full system (if approved).
What do you think?

@yawaramin
Copy link
Contributor

Sounds like an RBAC-based auth system would not be using basic auth, right? In that case we might as well use this PR to remove this 'basic auth' recipe from the cookbook altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants