Skip to content

Add configurable authentication#758

Merged
garrettjstevens merged 8 commits into
mainfrom
configurabe_authentication
Jun 22, 2026
Merged

Add configurable authentication#758
garrettjstevens merged 8 commits into
mainfrom
configurabe_authentication

Conversation

@garrettjstevens

Copy link
Copy Markdown
Contributor

This adds an extension point for configurable authentication. Draft for now, more info to come if this idea ends up working out.

@garrettjstevens

Copy link
Copy Markdown
Contributor Author

One thing I tried to do with this is to allow users to not have to click on a login button if there is only a single login type configured. I realized, however, that if the login flow opens a popup window, like with Google or Microsoft, then without the explicit user interaction of clicking on the login button, the browser blocks the popup window. I therefore made it so that users can skip clicking a login button only if there is a single login type configured and it doesn't need a popup window (which only applies to guest login for the built-in types, but could apply to custom auth types).

@garrettjstevens

Copy link
Copy Markdown
Contributor Author

I tried this out with a custom plugin. I manually added the header { 'X-Apollo-Custom': 'Test User;test@user.com' } to the login request, and it worked to create a user from that header. Here's the full plugin code:

import Plugin from "@jbrowse/core/Plugin";
import type PluginManager from "@jbrowse/core/PluginManager";
import type { Request } from "express";
import { version } from "../package.json";

export default class ApolloCustomAuthPlugin extends Plugin {
  name = "ApolloCustomAuthPlugin";
  version = version;

  apolloInstall(pluginManager: PluginManager) {
    pluginManager.addToExtensionPoint(
      "Apollo-RegisterCustomAuth",
      (
        customAuths: Map<
          string,
          {
            message: string;
            needsPopup: boolean;
            handler: (
              request: Request,
            ) => Promise<{ name: string; email: string }>;
          }
        >,
      ) => {
        customAuths.set("custom", {
          message: "Sign in with Custom Auth",
          needsPopup: false,
          handler: async (request: Request) => {
            const remoteUser = request.headers['x-apollo-custom'];
            if (!remoteUser || Array.isArray(remoteUser)) {
              throw new Error("Invalid remote user");
            }
            const [name, email] = remoteUser.split(";");
            return { name, email };
          },
        });
        return customAuths;
      },
    );
  }
}

Now I need to see if this works for a more complicated login type, e.g. an Oauth provider that's not Google or Microsoft.

@garrettjstevens garrettjstevens changed the title Add configurabe authentication Add configurable authentication Mar 13, 2026
@garrettjstevens garrettjstevens force-pushed the configurabe_authentication branch from e52b4cc to ecbfe8e Compare June 18, 2026 21:05
@garrettjstevens garrettjstevens marked this pull request as ready for review June 18, 2026 23:07
@garrettjstevens

Copy link
Copy Markdown
Contributor Author

This now includes documentation on how to use the extension point (preview here) and a link to an example repo that adds ORCID login to Apollo 3: https://github.com/GMOD/jbrowse-plugin-apollo-orcid-login

@garrettjstevens garrettjstevens force-pushed the configurabe_authentication branch from 18f70eb to ad0fc92 Compare June 22, 2026 17:20
@garrettjstevens garrettjstevens merged commit 8263420 into main Jun 22, 2026
7 checks passed
@garrettjstevens garrettjstevens deleted the configurabe_authentication branch June 22, 2026 21:55
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

Successfully merging this pull request may close these issues.

1 participant