Skip to content

Conversation

@ewels
Copy link
Member

@ewels ewels commented Sep 4, 2025

This PR introduces a complete authentication system for Seqera Platform with multiple subcommands for managing authentication credentials and configuration.

CleanShot.2025-09-21.at.00.32.54.mp4

Features

New nextflow auth command with subcommands:

  • nextflow auth login - Authenticate with Seqera Platform using OAuth2/PKCE flow
  • nextflow auth logout - Remove authentication credentials and clear configuration
  • nextflow auth status - Show current authentication status and user information
  • nextflow auth config - Display current authentication configuration

Auth0 Device Flow Authentication

  • Implements Auth0 device flow for secure authentication without requiring a local server
  • User-friendly flow: displays a code and opens browser to Auth0 verification URL
  • Automatic polling to detect when user completes authentication
  • Supports multiple Seqera environments (production, staging, development)
  • Personal Access Token (PAT) fallback for enterprise/custom deployments

Usage Examples

# Authenticate with Seqera Cloud (production)
nextflow auth login

# Authenticate with custom endpoint
nextflow auth login -u https://my-enterprise-seqera.com/api

# Check authentication status
nextflow auth status

# View current configuration
nextflow auth config

# Logout and clear credentials
nextflow auth logout

Technical Implementation

Core Components

  • CmdAuth: Main command handler with OAuth2 flow implementation
  • ColorUtil: ANSI color utility for enhanced terminal output
  • Comprehensive test suite: 36 tests covering all functionality

Authentication Flow

  1. Prompts for API endpoint (defaults to Seqera Cloud production)
  2. For Seqera Cloud: initiates Auth0 device flow
  3. Displays user code and opens browser to verification URL
  4. Polls Auth0 token endpoint until user completes authentication
  5. For enterprise: prompts for Personal Access Token
  6. Validates credentials and fetches user information
  7. Handles workspace/organization selection
  8. Updates Nextflow configuration with new credentials

Note

Introduces a new nextflow auth CLI with OAuth2 (Auth0) and PAT flows via nf-tower plugin, adds ANSI color utility, integrates into launcher, and includes comprehensive tests.

  • CLI:
    • Add CmdAuth command group with subcommands: login, logout, config, status.
    • Integrate auth into Launcher command registry.
    • Add ColorUtil for ANSI-colored terminal output.
  • nf-tower Plugin:
    • Implement io.seqera.tower.plugin.cli.AuthCommandImpl (extension of CmdAuth.AuthCommand).
      • Auth0 device flow (Cloud) and PAT entry (Enterprise), token generation/deletion, config read/write, workspace selection, and status display.
    • Register new extension point and bump nextflowVersion to 25.08.0-edge in plugins/nf-tower/build.gradle.
  • Tests:
    • Add tests for CmdAuth, ColorUtil, and AuthCommandImpl.
  • Misc:
    • Update author email in nextflow/trace/ReportObserver.groovy.

Written by Cursor Bugbot for commit 00b4590. This will update automatically on new commits. Configure here.

@netlify
Copy link

netlify bot commented Sep 4, 2025

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 238e387
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/68e7ab474482990008538faa

@ewels ewels force-pushed the nextflow-auth branch 8 times, most recently from e9b3f26 to c01e56b Compare September 6, 2025 19:41
@ewels ewels force-pushed the nextflow-auth branch 3 times, most recently from 5e79a3b to c5a3283 Compare September 20, 2025 23:32
@ewels

This comment was marked as resolved.

@ewels ewels changed the title WIP: First attempt at auth0 flow for nextflow auth login New command group: nextflow auth Sep 21, 2025
@ewels ewels marked this pull request as ready for review September 21, 2025 19:43
@ewels

This comment was marked as resolved.

@claude

This comment was marked as resolved.

@pditommaso
Copy link
Member

Let's start refactoring this as nf-seqera plugin (in the plugins directory, same as nf-tower)

@jorgee
Copy link
Contributor

jorgee commented Sep 26, 2025

I get confused a bit on how -url is managed.
In usage examples, it seems the -url is used to support login for enterprise, but inside the code it is also used to decide to use cloud dev, stage or prod.
To manage it, the code has a couple of maps with the api and Auth0 URLs, and Auth0 client Id for all environments hardcoded in the code. There is also a complex sequence to check if the URL is from platform (cloud) or enterprise and if it is enterprise then uses PAT instead of Auth0.

I think it is better to simplify it by -url is for enterprise with PAT and no url is for cloud. Moreover, instead of hardcoding all environments, keep just the production values as default and allow to test in other environments using env variables. In fact, we already have the TOWER_API_ENDPOINT, we just would need to add the ones for auth endpoint and client id.

What do you think about it?

@ewels
Copy link
Member Author

ewels commented Sep 26, 2025

@jorgee I think that we still need the logic to detect the 3 prod / stage / dev URLs for cloud - it's needed to trigger the logic to try the Auth0 flow rather than just booting people to use a PAT.

If we have that logic in the code, then I don't really see a reason to not also include the key and auth0 URL personally, it's only a handful of extra lines of code. And it'd be a swap for env vars. Given that I don't envision ever needing to test with any other auth0 URLs I'm not really sure it'd be any simpler..?

Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Set TOWER_ACCESS_TOKEN with new PAT.

Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Copy link
Member

@pditommaso pditommaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i'm not wrong seqera_auth take over both TOWER_ACCESS_TOKEN and standard config level tower.accessToken, which is against usual config pattern in which local config override global config.

Considering this happens silently it can be very confusing.

@ewels
Copy link
Member Author

ewels commented Oct 7, 2025

@pditommaso I'm not sure I understand? This PR uses standard config, there's nothing bespoke here:

  • Creates ~/.nextflow/seqera_auth.config
  • Adds includeConfig 'seqera_auth.config' to ~/.nextflow/config

Nextflow then loads tower.accessToken exactly as normal. No change to how env vars are used, or Nextflow config is parsed.

Example seqera_auth.config file:

// Seqera Platform configuration
tower {
    accessToken = 'eyJ........'
    endpoint = 'https://api.cloud.stage-seqera.io'
    enabled = true
    workspaceId = '123456789012345'  // org / workspace [Full name of workspace]
}

@pditommaso
Copy link
Member

I was missing this!

Adds includeConfig 'seqera_auth.config' to ~/.nextflow/config

ewels added 8 commits October 7, 2025 22:27
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Function does not expect tower. prefixes on config keys

Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
ewels added 2 commits October 8, 2025 09:57
Simplify code around status table for finding auth value origins

Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
@ewels
Copy link
Member Author

ewels commented Oct 8, 2025

@pditommaso thanks for the review - I believe that I have addressed all of your comments now.

I have leaned heavily into using PlatformHelper to fetch config attributes wherever they are used, so this acts as the single source of truth now.

There are two exceptions to this:

  • The auth stats table also grabs config manually so that it can show where things are defined (third table column says either nextflow config or env var $TOWER_xx - useful for debugging)
  • Several commands warn if an env var is found, as the recommended method is to use the Nextflow config and having both could result in confusing behaviour. These warnings grab the env var in order to tell if it's defined or not, but don't actually use its value.

Hope that makes sense and my edits are ok! 🙌🏻

Copy link
Member

@pditommaso pditommaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few comments. it would also be nice reduce the number of colors (ma

@ewels
Copy link
Member Author

ewels commented Oct 8, 2025

it would also be nice reduce the number of colors (ma

Not sure if you tested again after my changes, but I did make a start on toning the colours down a bit in 84c3584 already.

Main thing is that on my terminal, cyan is very similar to the default colour. You have the default terminal to bright green though, so the two look very different. I switched many instances of cyan out so it should look a bit better already.

I can do more to further reduce use of colour if you like. Note that NO_COLOR and the usual ANSI flags should work to totally remove colour if you want.

Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
@bentsherman bentsherman added this to the 25.10 milestone Oct 8, 2025
ewels added 2 commits October 8, 2025 23:00
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
…per.groovy [ci skip]

Co-authored-by: Phil Ewels <phil.ewels@seqera.io>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
@pditommaso
Copy link
Member

ok, i'll check again the colours. Do you mind to change the base branch to a non-master for a last cleanup round?

@ewels ewels changed the base branch from master to nextflow-auth October 9, 2025 14:04
@ewels
Copy link
Member Author

ewels commented Oct 9, 2025

Changed the PR target to a new nextflow-auth branch 👍🏻 (you should also be able to push directly to my fork to keep on this PR if you want).

Saw you merged the TOWER_AUTH_DOMAIN suggestion - should probably also comparable for TOWER_AUTH_ID and document both.

Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
@pditommaso pditommaso merged commit 696ac2d into nextflow-io:nextflow-auth Oct 9, 2025
5 of 7 checks passed
@ewels ewels mentioned this pull request Oct 9, 2025
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.

5 participants