-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
All: Add SAML support #11865
base: dev
Are you sure you want to change the base?
All: Add SAML support #11865
Conversation
This is due to changes in the lib package caused by adding SAML support. Currently, the CLI does not support SAML auth, this only fixes regular Joplin Server sync.
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
Thanks for creating this pull request! At the moment it has some issues related to the linter, which you should be able to fix by running |
I fixed the issues related to the linter. However, the server image does not build since the XML schema validator ( |
Hmm, if it's just to validate an XML schema I guess it's not worth adding a Java dependency? From their doc it looks like there's a TypeScript package too? |
xsd-schema-validator is replaced with xmllint-wasm, to remove any dependency to another program
I got rid of the Java dependency, and replaced the schema validator with |
Sorry to bump this, but is there any update about this? |
Hello, sorry for the lack of feedback yet. As this is a large pull request I will need more time to review it. The fact that it is deeply integrated to both the server and apps mean there will be maintenance concerns since unlike for example a sync target that works independently, the new code will have to be maintained by us probably over time. I don't assume it's possible to make things a bit more modular? i.e. most of the code in new files, and a few integration points here and there; |
Add comments, and clean up the code a bit
I don't think I can make the code more modular than it currently is. I refactored it a bit to help with your review (mostly by adding comments, but also by doing a bit of cleanup), and merged the current The new SAML sync target extends the base Joplin Server one, so on this topic I think I made things more modular than they were before by allowing the sync target to provide a session to Unfortunately since the SAML login process relies on a web browser, I didn't have a choice but to rely on a callback from a web page which means that I needed to use the And on the server, I had to modify If you have any tips about making this better, feel free to tell me so I can implement them. |
Thank you for the detailed explanation, it does help. I also need to go back to your top post and check the diagram again so I understand things at a higher level before diving into the code review. I will try to do that as soon as possible and will get back to you. |
This PR adds SAML support to Joplin.
Server
Based on the
samlify
library that provides the SAML logic flow for Joplin Server.This adds the following environment variables used as configuration parameters to Joplin Server :
SAML_ENABLED
: If set totrue
, enables SAML support.DISABLE_BUILTIN_LOGIN_FLOW
: If set totrue
, all auth requests MUST go though SAML. Users can't log-in using Joplin-specific credentials and/or LDAP.SAML_IDP_CONFIG_FILE
: Should be a path to an XML file containing the metadata for the Identity Provider (IDP).SAML_SP_CONFIG_FILE
: Should be a path to an XML file containing the metadata for the Service Provider (SP, in this case Joplin).SAML_ORGANIZATION_DISPLAY_NAME
: Name of the organization, as shown on the log-in screen. Optional.The XML files are standard SAML IDP/SP metadata that should be created by the identity solution.
Clients
As for the clients themselves, no additional libraries are needed, since the actual log-in process is happening in a web browser, outside of Joplin itself.
It also adds a new sync target, based on the one for Joplin Server: "Joplin Server (Beta, SAML)". We kept "Beta" in the name for this since the main Joplin Server target itself is currently considered as such.
Important
The log-in flow uses a callback to a
joplin://
URL, and thus requires that only one instance of Joplin is running at any given time. This is important for the desktop client, since the single instance lock is not enforced in thedev
environment.Log-in flow
The log-in process differs slightly if started from within a client or within the server web interface.
Testing and development
For development purposes, we used
saml-idp
as the Identity Provider, as it allows to quickly create new users on the fly and is simple to set up. After generating the keypair (look at thesaml-idp
documentation to see how), just runningnpx saml-idp --acsUrl 'http://localhost:22300/api/saml' --audience http://localhost:22300 --issuer 'saml-idp'
is enough to get a test Identity Provider running, assuming that Joplin Server is running onlocalhost:22300
.Since
saml-idp
does not support generating SP metadata, here is a sample configuration for the Service Provider part :