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

Copy link

netlify bot commented Sep 4, 2025

Deploy Preview for nextflow-docs-staging ready!

Name Link
🔨 Latest commit 24d0865
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/68d05552c5fb4f00087bbbd6
😎 Deploy Preview https://deploy-preview-6380--nextflow-docs-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@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 2 times, most recently from be9d924 to 5e79a3b Compare September 20, 2025 23:30
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>
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>
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>
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>
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>
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 Sep 20, 2025

Struggling to get the tests to pass. Even master is failing for me locally, whilst passing on GitHub. Not sure what's wrong.

@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
Copy link
Member Author

ewels commented Sep 21, 2025

@claude Please review this pull request and provide feedback on:

  • Code quality and best practices
  • Potential bugs or issues
  • Performance considerations
  • Security concerns
  • Test coverage

Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.

Use gh pr comment with your Bash tool to leave your review as a comment on the PR.

Copy link

claude bot commented Sep 21, 2025

Claude encountered an error —— View job

Failed with exit code 128

I'll analyze this and get back to you.

} else {
// Reset only what was set
if (bold) fmt = fmt.boldOff()
if (dim) fmt = fmt.a(Attribute.INTENSITY_BOLD) // Reset dim
Copy link

Choose a reason for hiding this comment

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

Bug: Colorize Method Incorrectly Applies Bold Formatting

When fullReset is false, the colorize method attempts to reset dim formatting using Attribute.INTENSITY_BOLD. This applies bold formatting instead of returning the text to normal intensity, causing text to appear bold when it should be undimmed.

Fix in Cursor Fix in Web

// Check if TOWER_WORKFLOW_ID environment variable is set
def envWorkspaceId = System.getenv('TOWER_WORKFLOW_ID')
if (envWorkspaceId) {
println "\nDefault workspace: ${ColorUtil.colorize('TOWER_WORKFLOW_ID environment variable is set', 'yellow')}"
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect Environment Variable Check in Nextflow Auth

The nextflow auth commands incorrectly check for the TOWER_WORKFLOW_ID environment variable when configuring and displaying the default workspace. This prevents the system from recognizing the intended TOWER_WORKSPACE_ID environment variable for workspace selection.

Additional Locations (1)

Fix in Cursor Fix in Web

@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?

Comment on lines +690 to +698
if (isCloudEndpoint(apiUrl)) {
def tokenId = decodeTokenId(existingToken as String)
deleteTokenViaApi(existingToken as String, apiUrl, tokenId)
} else {
println " - Enterprise installation detected - PAT will not be deleted from platform."
}

removeAuthFromConfig()

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if there was a previous token already defined in the config. Could it be deleted by mistake?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it will be deleted, by design. Maybe we could add a confirmation prompt?

@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..?

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.

3 participants