azukaar / Cosmos-Server

☁️ The Most Secure and Easy Selfhosted Home Server. Take control of your data and privacy without sacrificing security and stability (Authentication, anti-DDOS, anti-bot)
https://cosmos-cloud.io
Other
3.13k stars 112 forks source link

[FEAT]: Support header based authentication #66

Closed jwr1 closed 1 year ago

jwr1 commented 1 year ago

Feature Description

I'd like Cosmos to have support for header-based authentication, which is used in several applications like FireflyIII, Snipe-IT, and probably others. Basically, Cosmos would need an option to set headers for the username and email when signed in (and maybe redirect to Cosmos when signed out), these could either be hardcoded as REMOTE_USER and REMOTE_USER_EMAIL respectively, or we could allow users to modify them. I'd assume these would be options under each URL's settings since headers directly correlate to the routes. For reference here's the page for implementing this sort of remote authentication with FireflyIII, and here's the RFC that documents the header.

I can definitely help with the implementation if you'd like. I'd probably be a little slower though as I don't have experience with go (most of what I do is JS/TS/node).

azukaar commented 1 year ago

This is suppoorted as x-cosmos-user and x-cosmos-role, you can use the var AUTHENTICATION_GUARD_HEADER to tell firefly where to look for this value

jwr1 commented 1 year ago

That's awesome! Didn't realize this already existed. Is there also a header for the email as well, or is it just the username?

azukaar commented 1 year ago

Just for the username, for privacy reason I didnt want to leak the email address