Skip Navigation

SSO with automatic user creation

I'm considering adding an SSO process in front of my self-hosted apps such as Nextcloud, Calibre-Web and Immich. The thing I'm thinking about, is do I need to make two accounts for each user I want to add? If I have a new user, do I need to make an account for both the SSO provider and the protected app such as Nextcloud? Or does Nextcloud (or some other app) automatically create a new account upon the first authentication with the SSO provider?

Also, which SSO provider do y'all recommend? I would like to have one with a web UI where I can manage the users :)

7
7 comments
  • I use Authelia, and my users are backed by my LDAP server. I basically managed my users directly in LDAP through Apache Directory Studio. If you want something with built-in user management, I believe Keycloak might be a good place to start.

    Also, you can use Nextcloud as an OIDC provider and let it be your SSO provider. For apps that don't support OIDC, you may be able to put them behind OAuth2Proxy and point that your Nextcloud.

    It depends on the protected app. Some let you delegate to external auth and will create the account (e.g. Nextcloud) and others may expect some kind of HTTP header containing an identifier to associate with an existing local user (e.g Calibre Web). Most apps I've worked with that support OAuth2 usually handle creating the account in the app automatically - the app takes care of that, not the SSO provider.

    You'd need to read the docs for the apps you want to have behind SSO to see how each works with external users.

  • If the app supports SSO and allows user creation, then it's just a matter of passing the user claims such as username or email which the app expects from your provider.

    I use Authentik as my solution, which uses a GUI for user management and supports all major SSO options, from MFA, to OIDC, SAML, LDAP and more.

  • I ended up just making my own helper container for authelia. It can generate a link that expires after a set time and only allows a set number of users to access. Then I can just give the link to whoever I want to join and they can fill in their own username and pwd. It then adds them to the authelia user db with the correct groups and PW hashing. Only issue is I have to manually restart authelia for the changes to take effect. Eventually I want to see if I can automate that.

    I'm still working on editing the configuration through the app though. I want to be able to change the access control rules, etc.

    As far as having the services behind authelia automatically detect and login the user, that will depend on the service, but authelia does pass user credentials and login status in the request headers. Many of the services I host were created myself, so it's pretty trivial to have it automatically "log in" from the authelia sign on.

    • set up a LDAP directory server (i use openldap)
    • create users on the LDAP directory server
    • setup all services/applications to authenticate users aginst the LDAP server
  • I found that it really depends on the app and how they've set it up. For the vast majority, the users in your SSO will be added to the other app when they first login. I use Authentik and Nextdoor, and the user is automatically created from details from Authentik. Generally you can enable multiple login types so can play with SSO whilst still enabling access until it works. You can usually switch off non-SSO access afterwards too.

    You set which field defines the user (e.g. username or email). If there is already a user then it'll just login to that account you already created, so you can also create a user in both.

    You can limit access to certain groups of users in Authentik. You can also setup headers that get passed along to apps (e.g. in Nextcloud you can setup a size limit for each group that gets passed on to Nextcloud when they first register - the Authentik or Nextcloud documentation tells you how).

    I found quite a few apps don't have SSO functionality, and I usually end up doing a reverse proxy pass through Authentik. Nginx Proxy Manager first goes to Authentik, you login then it'll pass you to the app. If already logged into Authentik, NPM takes you directly to the app. I switched off login altogether on the apps, especially for tools where you don't need users (e.g. Stirling PDF). Only logged users get to the app. Authentik can forward any headers you set so I have a feeling you can use it for the app's own login (though not new users) but not managed to work it out.

    One app I tried recently had SSO but you couldn't enable access to the main household for new SSO users so had to create an account in the app first, then SSO would let users login. I ended up not using that app for other reasons anyway.

    I do recommend Authentik and you can setup access one by one so definitely try it and see.

  • I use user_oidc on one of my nextcloud instance. It has auto provisioning support, which will create nextcloud user on first login.

  • I'm using Keycloak and Traefik as reverse proxy, and some apps don't have integration with SSO, so I turn off authentication and use traefik-auth in front of them, which works ok for my use case.

    For the rest, it depends, and gotta take a look at their documentation.

7 comments