Skip to content

[25.1] Support credentials(secrets/variables) in tool requirements#19084

Merged
mvdbeek merged 300 commits intogalaxyproject:release_25.1from
arash77:add-secrets-to-tools
Oct 8, 2025
Merged

[25.1] Support credentials(secrets/variables) in tool requirements#19084
mvdbeek merged 300 commits intogalaxyproject:release_25.1from
arash77:add-secrets-to-tools

Conversation

@arash77
Copy link
Member

@arash77 arash77 commented Oct 30, 2024

Related to #19196
Closes #17511

Summary

This PR implements a comprehensive tool credentials system for Galaxy, allowing tools to securely access external services by defining authentication credentials (variables and secrets) in tool requirements. The system provides secure credential management while keeping sensitive information separate from tool definitions.
Youtube Video
Blog Post in Galaxy Hub
Galaxy Tool XML Schema
Valut Documentations on Credentials

Key Features

🔐 Credential Definition in Tools

  • Tools can define credential requirements using <credentials> elements within <requirements>
  • Support for both variables (non-sensitive config like URLs, usernames) and secrets (sensitive data like passwords, API keys)
  • Optional/required credential validation
  • Environment variable injection into tool execution context

🗃️ Secure Storage & Management

  • Integration with Galaxy's vault system for secure secret storage
  • User-specific credential isolation by tool and service
  • Credential groups for organizing multiple credential sets
  • Database schema with proper foreign key relationships and constraints

🌐 REST API

  • Complete CRUD operations for credential management
  • User credential listing with optional definition inclusion
  • Group-based credential organization
  • Secure deletion with vault cleanup

🎨 Frontend Integration

  • Unified credential management UI for every tool
  • Workflow-level credential status display
  • Multi-tool credential coordination
  • Real-time credential validation and feedback

⚙️ Tool Execution Integration

  • Automatic credential injection as environment variables
  • Job context tracking for credential usage
  • Support for tool proxies and various tool types
  • Backward compatibility with existing tools

Tool Definition Example

<requirements>
    <credentials name="aws_s3" version="1.0" label="AWS S3 Access" description="Credentials for accessing AWS S3 buckets">
        <variable name="region" inject_as_env="AWS_REGION" optional="false" label="AWS Region" description="The AWS region where your S3 bucket is located" />
        <secret name="access_key" inject_as_env="AWS_ACCESS_KEY_ID" optional="false" label="Access Key ID" description="Your AWS access key ID" />
        <secret name="secret_key" inject_as_env="AWS_SECRET_ACCESS_KEY" optional="false" label="Secret Access Key" description="Your AWS secret access key" />
    </credentials>
</requirements>

Screenshots

Tool Run Form

Tool with required credentials, but the user does not have a selection. The Run Tool button is disabled.

Screenshot 2025-09-25 at 12 47 54

Tool with required credentials, and the user has a selection for every service

Screenshot 2025-09-25 at 12 07 30

Tool with optional credentials, but the user does not have a selection.

Screenshot 2025-09-25 at 12 07 49

Tool with required credentials, and the user has a selection for every service.

Screenshot 2025-09-25 at 12 08 18

Tool with required and optional credentials, and the user does not have a selection. The Run Tool button is disabled.

Screenshot 2025-09-25 at 12 49 57

Tool with required and optional credentials, and the user only has a selection for the required credentials.

Screenshot 2025-09-25 at 12 10 50

Manage & Select Credentials Groups Modal for Tool. User can create, select or delete a group.

Screenshot 2025-09-25 at 12 12 35

Manage & Select Credentials Groups Modal for Tool

Screenshot 2025-09-25 at 12 12 52

Workflow Run Form

Workflow Editor

Screenshot 2025-09-25 at 12 14 47

Workflow Editor

Screenshot 2025-09-25 at 12 14 53

Workflow simple run with required credentials, but the user does not have a selection. The Run Workflow button is disabled.

Screenshot 2025-09-25 at 14 50 41

Workflow run form with required credentials, but the user does not have a selection. The Run Workflow button is disabled.

Screenshot 2025-09-25 at 14 54 02

Workflow simple run with optional credentials, but the user does not have a selection.

Screenshot 2025-09-25 at 15 03 38

Workflow simple run with optional credentials, but the user does not have a selection.

Screenshot 2025-09-25 at 15 03 52

Manage & Select Credentials Groups Modal for Tools in Workflow. User can create, select or delete a group for each tool.

Screenshot 2025-09-25 at 14 55 07

All User Credentials Management

Screenshot 2025-09-25 at 12 13 35

Database Schema

erDiagram
    galaxy_user ||--o{ user_credentials : "owns"
    user_credentials ||--o{ credentials_group : "contains"
    user_credentials ||--o| credentials_group : "current_group"
    credentials_group ||--o{ credential : "stores"
    job ||--o{ job_credentials_context : "uses"
    user_credentials ||--o{ job_credentials_context : "references"
    credentials_group ||--o{ job_credentials_context : "selected_group"

    galaxy_user {
        int id PK
    }

    user_credentials {
        int id PK
        int user_id FK
        string source_type
        string source_id
        string source_version
        string name
        string version
        int current_group_id FK
        datetime create_time
        datetime update_time
    }

    credentials_group {
        int id PK
        int user_credentials_id FK
        string name
        datetime create_time
        datetime update_time
    }

    credential {
        int id PK
        int group_id FK
        string name
        boolean is_secret
        boolean is_set
        string value
        datetime create_time
        datetime update_time
    }

    job {
        int id PK
    }

    job_credentials_context {
        int id PK
        int job_id FK
        int user_credentials_id FK
        string service_name
        string service_version
        int selected_group_id FK
        string selected_group_name
    }
Loading

API Endpoints

  • GET /api/users/{user_id}/credentials?source_type=tool&source_id={tool_id}&source_version={tool_version}&include_definition={true|false} - List user credentials
  • POST /api/users/{user_id}/credentials - Provide credentials
  • PUT /api/users/{user_id}/credentials - Update credential group selection
  • PUT /api/users/{user_id}/credentials/{user_credentials_id}/groups/{group_id} - Update specific group
  • DELETE /api/users/{user_id}/credentials/{user_credentials_id} - Delete service credentials
  • DELETE /api/users/{user_id}/credentials/{user_credentials_id}/groups/{group_id} - Delete specific group

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. Create a tool with credentials (use the sample file test/functional/tools/secret_tool.xml)
      2a. Open the tool run form
      2b. Create a workflow using the tool and try to run it
    2. After creating a group for a tool, you can manage them in the User Preferences -> Credentials Management

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.


```xml
<requirements>
<secret type="vault" user_preferences_key="some_tool|api_key" inject_as_env="some_tool_api_key" label="API Key" required="true"/>
Copy link
Member

Choose a reason for hiding this comment

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

Do any of the use cases involve multiple tools with different IDs requesting the same secret? If not - I would make the tool id (without a version) an implicit prefix here and just attach some similar field as the suffix. This isolation feels more secure-ish to me - we wouldn't risk tools picking up other keys accidentally.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, in some use cases, maybe in the future, it will be good to access an api_key or a token for multiple tools.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi John, Arash, with @Marie59 and @jeremyfix we have such use case (if I well understand) where separate tools need the same credential (here this is Copernicus marine system credentials), so I confirm that this is already a reality ;) It appears to me, at least for ecology and related environmental sciences, that it will be the case for many data providers as Copernicus for satellites remote sensing data and others.

@arash77 arash77 force-pushed the add-secrets-to-tools branch from f14c777 to bdf8667 Compare November 28, 2024 14:15
Copy link
Member

@nuwang nuwang left a comment

Choose a reason for hiding this comment

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

Nice to see this feature coming in. One thing I was wondering about though, should this be a requirement or be injected through the <environment_variables> section following the precedent here?
#15300

@arash77 arash77 force-pushed the add-secrets-to-tools branch 5 times, most recently from dedb684 to ff3ee10 Compare December 3, 2024 16:45
@arash77 arash77 force-pushed the add-secrets-to-tools branch 11 times, most recently from ab6f860 to 7c8b58f Compare December 19, 2024 15:04
@arash77 arash77 force-pushed the add-secrets-to-tools branch from 971fa21 to 64d382c Compare January 2, 2025 09:11
@arash77 arash77 force-pushed the add-secrets-to-tools branch 3 times, most recently from 3530c3c to 18282cc Compare January 20, 2025 13:34
itisAliRH and others added 13 commits October 7, 2025 16:07
Updates credential validation to properly handle optional tool credentials by modifying warning conditions and status determination logic.

Enhance documentation for status variant in user credentials composables.

Changes exclamation icon display logic to show warnings when either required credentials are missing OR optional credentials are partially provided.

Refines status computation to return appropriate states based on whether tools have required credentials, preventing incorrect success states when no credentials are needed.
Disables the run button and displays informative tooltip when required tool credentials are not provided by the user.

Ensures workflows cannot be executed with incomplete credential configuration, preventing runtime errors and improving user experience through clear feedback.
Updates the credentials update and delete endpoints to require user credentials ID in the URL path, improving API consistency and enabling proper resource identification.

Modifies the PUT endpoint from `/credentials/group/{group_id}` to `/credentials/{user_credentials_id}/group/{group_id}` and updates the DELETE endpoint to include `/group/` segment for better REST API design.

Updates all related client code, tests, and API schema to handle the new endpoint structure with the additional user credentials ID parameter.

Co-authored-by: Arash Kadkhodaei <arash77.kad@gmail.com>
Relocates workflow credentials components from generic Common directory to specific Workflow/Run directory to improve code organization and maintainability.

Updates import paths accordingly to maintain functionality while establishing clearer component hierarchy.
@mvdbeek mvdbeek force-pushed the add-secrets-to-tools branch from ecdbe91 to a61aca1 Compare October 7, 2025 14:54
@mvdbeek
Copy link
Member

mvdbeek commented Oct 7, 2025

The selenium errors don't fail elsewhere, this does look to be related.

@mvdbeek mvdbeek mentioned this pull request Oct 7, 2025
4 tasks
Wraps credential-related content in nested template to ensure proper rendering regardless of credential presence.

Previously, the outer template with conditional rendering could cause display issues when credentials were absent.
Moves credential-related UI elements from FormCard component to WorkflowRunDefaultStep to improve component separation of concerns.

Uses template slots to allow parent components to customize title area content rather than passing credential data as props.
@ahmedhamidawan
Copy link
Member

ahmedhamidawan commented Oct 7, 2025

The target for this PR needs to be changed from dev to release_25.1.

Once this is merged, the database version will have to be updated again like #21017.

@guerler

@arash77
Copy link
Member Author

arash77 commented Oct 8, 2025

Test Galaxy packages / Test (3.13) seems to be failing on other PRs too, so it’s not related to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool language for defining and requiring specific secrets