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

luci-base: add support for setting cookie when using non login based authentication (mr available if wanted) #7158

Open
reidar-cederqvist opened this issue Jun 13, 2024 · 1 comment

Comments

@reidar-cederqvist
Copy link


This is a request to merge a new feature.

Steps to reproduce:

Use ?sid= to login to a page in LuCI, if you now click on a link, you will no longer be logged in. This is by design.
I have at work made a patch to LuCI that introduces a config option in admin->auth called force_cookie when this is set to true,
LuCI will set the cookie for login allowing subsequent navigation in the menu to be authenticated with the same sid as the initial page visit.

Actual behavior:

as described above.

Expected behavior:

By default, this would not be turned on but enabled if you add "param:sid" as an auth->method, and set auth->force_cookie = true

Additional Information:

I have a patch already available, but I wanted to check if this would be of interest before creating a merge request.

@mikma
Copy link
Contributor

mikma commented Sep 6, 2024

I also want to be able to set the sysauth_http(s) cookie, but I want it to use the value of a form parameter. (I have a custom sysauth.ut template that uses the POST method.) I'm using the patch below. (I have made some additional changes that I removed, and I haven't tested the code I posted.)

@@ -911,20 +915,32 @@
 			if (!session && resolved.ctx.auth.login) {
 				let user = http.getenv('HTTP_AUTH_USER');
 				let pass = http.getenv('HTTP_AUTH_PASS');
+				let sysauth = http.formvalue('luci_sysauth');
 
 				if (user == null && pass == null) {
 					user = http.formvalue('luci_username');
 					pass = http.formvalue('luci_password');
 				}
 
+				if (sysauth)
+					session = session_retrieve(sysauth);
+				else 
 				if (user != null && pass != null)
 					session = session_setup(user, pass, resolved.ctx.request_path);

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

No branches or pull requests

2 participants