Organizations that already sign people in through an intranet portal or an internal dashboard rarely want a second password for every tool behind it. AnythingLLM's Simple SSO passthrough lets that existing system sign a person straight into a self-hosted instance through a one-time login link, which the AnythingLLM developer API issues for that person's account.

The handoff is a single API call. The trusted system asks AnythingLLM for a temporary token for a user ID, then sends that user's browser to the returned /sso/simple address. Each link works once and expires after 10 minutes, and the browser session it opens lasts 30 days. Whoever holds the API key can mint a link for any account, administrators included, so AnythingLLM's documentation recommends a dedicated key that can be deleted on its own and an instance that is not exposed to the public internet.

Simple SSO only works on an instance already in multi-user mode, switched on under Security in the instance settings, and the person signing in needs an existing account on the Users page. On a Docker installation the feature is controlled by SIMPLE_SSO_ENABLED in the mounted .env file, which the server reads only when it starts. Username and password sign-in keeps working beside the links unless a second variable, SIMPLE_SSO_NO_LOGIN, removes the login page for every account.

Steps to enable simple SSO in AnythingLLM:

  1. Open the .env file in AnythingLLM's Docker storage directory with sudo nano.
    $ sudo nano "$HOME/anythingllm/.env"

    The container reads this file as /app/server/.env. Only root and UID 1000, which owns the directory with mode 700, can open files inside it, and running nano through sudo works for both. sudoedit refuses to edit a file in this directory on current Ubuntu releases. The existing lines hold the keys AnythingLLM uses to sign sessions and encrypt saved credentials, so they stay as they are. An installation stored elsewhere uses its own .env path.

  2. Enable Simple SSO by typing SIMPLE_SSO_ENABLED=“true” on its own line below the existing settings.
    SIMPLE_SSO_ENABLED="true"

    AnythingLLM only checks that the variable exists, so any value turns Simple SSO on, false included. Turning it off again means deleting the line and restarting the container.

    Do not add SIMPLE_SSO_NO_LOGIN at the same time. With both variables set, the username and password login is refused for every account, administrators included, and invitations stop working, so a broken link-issuing system would leave nobody able to sign in.

  3. Close nano with the new line saved.

    nano writes into the existing file, so its UID 1000 owner and mode are unchanged and the container can still read it. The running server ignores the new line until the next restart.

  4. Restart the AnythingLLM container so the server reads the new variable.

    The web interface and the developer API stop answering for about half a minute while the server starts again.

    $ docker restart --timeout 30 anythingllm
    anythingllm

    anythingllm is the container name from the Docker installation. Signed-in browsers keep their sessions across the restart. A variable passed with -e when the container was created is not reread on restart; changing one of those requires recreating the container.

  5. Click the wrench icon at the bottom of the sidebar to open the instance settings as an administrator.

    In multi-user mode only Admin accounts can create developer API keys.

  6. Expand Tools in the settings sidebar.
  7. Click Developer API under Tools.
  8. Click Generate New API Key on the API Keys page.
  9. Enter SSO login service in the Name field.

    A key used only for login links can be deleted to stop all new links at once without breaking other integrations that call the API.

  10. Click Create API Key to generate the key.

    This key can issue a login link for any account on the instance, including administrators, and can use the rest of the developer API to read and change workspaces, users and documents. AnythingLLM shows it in full in the next dialog and keeps it readable on the API Keys page for every administrator, so it belongs only in the system that issues the links.

  11. Copy the new key with the copy icon beside it.

    A green check replaces the icon once the key is on the clipboard.

  12. Paste the key at a hidden read prompt on the machine that will request the links.
    $ read -rs ANYTHINGLLM_API_KEY

    Nothing appears while pasting, and Enter ends the input. The key is kept only in this shell's memory, outside the shell history.

  13. List the instance's users through the developer API to find the numeric ID of the account that will sign in.
    $ curl -sS -H @- \
      http://localhost:3001/api/v1/users \
      <<< "Authorization: Bearer $ANYTHINGLLM_API_KEY"
    {"users":[{"id":1,"username":"admin","role":"admin"},{"id":2,"username":"jordan","role":"default"}]}

    The Users page in the settings does not show these IDs. -H @- takes the Authorization header from the here-string, so the key never appears in the process list on the host. An instance on another host uses its own address in place of localhost:3001.

  14. Request a temporary login token for user ID 2.
    $ curl -sS -H @- \
      http://localhost:3001/api/v1/users/2/issue-auth-token \
      <<< "Authorization: Bearer $ANYTHINGLLM_API_KEY"
    {"token":"allm-tat-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX","loginPath":"/sso/simple?token=allm-tat-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX"}

    Until it is used or expires 10 minutes later, the token signs in as jordan for anyone who opens the link, so it must not be pasted into chats, tickets or logs.

    Requesting another token for the same user cancels the previous one. The reply Simple SSO is not enabled means the server is still running without SIMPLE_SSO_ENABLED, and Multi-User mode is not enabled means the instance is still in single-user mode.

  15. Check that http://localhost:3001 followed by the loginPath value opens AnythingLLM signed in as jordan in a private browser window.
    http://localhost:3001/sso/simple?token=allm-tat-XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX

    A private window starts without the administrator's session, as the user's own browser would, and in a real integration the trusted system redirects the user's browser to this address instead. The initials JO in the top-right corner come from the signed-in username, in place of the administrator's AD. An account with the Default role that has not been added to a workspace sees the notice about workspace access, and the session stays valid for 30 days.

  16. Check that the same login link shows an invalid-token error when it is opened again in a new private window.

    AnythingLLM deletes a token the first time it is used, so the second visit shows [001] An error occurred while validating the token: Invalid token. and leaves the window signed out. A link opened after its 10 minutes is refused the same way, with Token expired. in place of Invalid token.

Share this guide