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

Header authentication #180

Merged
merged 14 commits into from
Dec 4, 2024
Merged

Conversation

albinmedoc
Copy link
Contributor

No description provided.

@albinmedoc albinmedoc mentioned this pull request Nov 30, 2024
@cmintey
Copy link
Owner

cmintey commented Dec 1, 2024

Can you also add a global flag to completely disable this functionality? HEADER_AUTH_ENABLED and default it to false?

I don't have too much knowledge of header auth, but I do know that it can be pretty dangerous if the upstream proxy is not configured properly. Obviously that is not Wishlist's job to know about that or enforce it, but I think there should be a disclaimer in the docs about that. Maybe something like

Warning

When header authentication is enabled, Wishlist makes no assumptions about the validity of the headers. It is up to you to have your proxy properly configured. An improperly configured proxy could allow anyone to gain access to the application by forging the headers.

@cmintey
Copy link
Owner

cmintey commented Dec 1, 2024

Couple other things to consider

  • How will this play with the "setup wizard" flow
  • Add this to the signup flow for users who receive an invite token/url
  • Should we block users who were created via headers from changing or resetting their password (change password flow won't work because the password is blank)

@albinmedoc albinmedoc force-pushed the header-authentication branch from d43e103 to 14da946 Compare December 1, 2024 19:00
@albinmedoc
Copy link
Contributor Author

Couple other things to consider

  • How will this play with the "setup wizard" flow
  • Add this to the signup flow for users who receive an invite token/url
  • Should we block users who were created via headers from changing or resetting their password (change password flow won't work because the password is blank)
  • I have now made it so that the first user goes through the setup wizard regardless of whether proxy auth is enabled and values are sent in headers. If you want the first user to work with proxy auth, you need to set the username to the same as what will be sent with the headers.
  • Should this automatically create the user and add them to the group that the invitation pertains to?
  • I can make it so this is blocked in the UI. It doesn't really matter if the user changes the password or not, but it might be good to hide it to avoid showing unnecessary things.

@cmintey
Copy link
Owner

cmintey commented Dec 1, 2024

Couple other things to consider

  • How will this play with the "setup wizard" flow
  • Add this to the signup flow for users who receive an invite token/url
  • Should we block users who were created via headers from changing or resetting their password (change password flow won't work because the password is blank)
* I have now made it so that the first user goes through the setup wizard regardless of whether proxy auth is enabled and values are sent in headers. If you want the first user to work with proxy auth, you need to set the username to the same as what will be sent with the headers.

* Should this automatically create the user and add them to the group that the invitation pertains to?

* I can make it so this is blocked in the UI. It doesn't really matter if the user changes the password or not, but it might be good to hide it to avoid showing unnecessary things.
  • Sounds good
  • I think yea, create the user automatically and assign them to the group in the invite. Users can also be invited without a group, so use the default group (if set)
  • I think just make the password reset fields disabled on the user account page. If a user goes through the password reset flow and doesn't have a password, then we can allow that, I suppose

@albinmedoc albinmedoc force-pushed the header-authentication branch from 8ac1e52 to 6076398 Compare December 1, 2024 22:42
@albinmedoc albinmedoc force-pushed the header-authentication branch from 6076398 to fd44cae Compare December 2, 2024 15:53
@albinmedoc albinmedoc marked this pull request as ready for review December 2, 2024 16:13
@albinmedoc
Copy link
Contributor Author

@cmintey This is now ready for a review.

I have implemented a function for creating a user, just so don't have duplicated code everywhere.

Copy link
Owner

@cmintey cmintey 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. Just a suggestion to add some logs when the required headers are missing. Can just use console.log since I haven't set up any real logging yet


if (!user) {
if (!env.HEADER_EMAIL || !env.HEADER_NAME) {
return fail(400, { username: username, password: "", incorrect: true });
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe add a log message here that the header variables are missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will fix!

const name = request.headers.get(env.HEADER_NAME);
const email = request.headers.get(env.HEADER_EMAIL);
if (!name || !email) {
return fail(400, { username: username, password: "", incorrect: true });
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe add a log message here as well that the required headers are missing from the request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will fix!

@albinmedoc
Copy link
Contributor Author

I have added logging @cmintey

@cmintey cmintey merged commit 8742015 into cmintey:main Dec 4, 2024
2 checks passed
@albinmedoc albinmedoc deleted the header-authentication branch December 4, 2024 07:24
@albinmedoc albinmedoc mentioned this pull request Dec 4, 2024
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.

2 participants