Authentication overview
Deepcode's technology, acquired by Snyk in 2020, is now a core component of Snyk Code, focusing on static application security testing (SAST) to identify vulnerabilities in source code. Authentication for Deepcode's capabilities is handled through the Snyk platform, primarily utilizing API tokens to secure interactions across various developer tools and automation workflows. This approach ensures that all requests to Snyk's analysis engines are properly authorized, enabling seamless integration into development environments and CI/CD pipelines.
The authentication model is designed to support both individual developer access and team-based enterprise deployments, with granular control over permissions and access levels. Developers typically authenticate via the Snyk CLI, IDE plugins, or by configuring CI/CD systems with API tokens generated from the Snyk web interface. This centralized management simplifies credential handling while maintaining security standards for code analysis operations.
Supported authentication methods
Deepcode's integrated technology, as part of Snyk Code, supports several authentication methods tailored for different use cases, emphasizing API tokens for programmatic and automated access.
| Method | When to Use | Security Level |
|---|---|---|
| API Tokens | Programmatic access, CI/CD pipelines, Snyk CLI, IDE plugins | High (when managed securely) |
| OAuth 2.0 (for Git Integrations) | Connecting Snyk with Git repositories (e.g., GitHub, GitLab, Bitbucket) | High (delegated authorization) |
| SAML / SSO | Enterprise environments requiring single sign-on through an identity provider | Very High (centralized identity management) |
| Personal Access Tokens (PATs) | Specific integration scenarios or custom scripts requiring limited scope access | High (granular control) |
API Tokens
API tokens are the primary method for authenticating with Snyk services, including those powered by Deepcode. These tokens are alphanumeric strings that grant access to your Snyk account and its associated organizations and projects. They are essential for automated scanning, integrating with build systems, and using the Snyk CLI or IDE plugins. Each token is tied to a specific user or service account and can be revoked if compromised or no longer needed. For detailed information on API token usage, refer to the Snyk API key authentication documentation.
OAuth 2.0 for Git Integrations
When integrating Snyk with source code management systems like GitHub, GitLab, or Bitbucket, Snyk utilizes OAuth 2.0 for delegated authorization. This allows Snyk to access your repositories without direct access to your login credentials, enabling it to pull code for analysis and report vulnerabilities directly within your version control system. The OAuth flow typically involves granting Snyk specific permissions through your Git provider's interface. More information on this integration can be found in the Snyk Git repository integration guide.
SAML / SSO
For enterprise customers, Snyk supports Security Assertion Markup Language (SAML) for single sign-on (SSO) integration. This allows organizations to manage user authentication through their existing identity providers (IdPs), such as Okta, Azure AD, or Google Workspace. SAML/SSO streamlines user access, enhances security through centralized identity management, and simplifies compliance. Users authenticate once with their IdP and gain access to Snyk without needing separate credentials. Learn more about Snyk's SSO capabilities.
Personal Access Tokens (PATs)
Similar to API tokens, Personal Access Tokens (PATs) can be used for more granular control over specific integrations or custom scripts. While API tokens typically grant broad access to a Snyk account, PATs might be configured with more restricted scopes, depending on the Snyk platform's evolving capabilities and the specific integration requirements. For current best practices regarding PATs, consult the Snyk documentation on Personal Access Tokens.
Getting your credentials
To obtain the necessary credentials for authenticating with Deepcode's integrated technology via Snyk, follow these steps:
-
Create a Snyk Account: If you don't already have one, sign up for a Snyk account on the Snyk website. A free tier is available for individual developers.
-
Log in to the Snyk Web UI: Access your Snyk dashboard by logging in with your credentials.
-
Navigate to Account Settings: In the Snyk web interface, typically click on your profile icon or username in the top right corner, then select 'Account settings' or 'General settings'.
-
Generate API Token: Under the 'API token' section (or similar, depending on UI updates), you will find your unique API token. If it's not visible, you may need to generate a new one. Copy this token securely.
For detailed instructions, refer to the Snyk documentation on how to get your API token.
-
Configure Integrations (for OAuth/SAML):
- Git Integrations: To connect Snyk with your Git repositories, navigate to 'Integrations' in the Snyk UI. Select your Git provider (e.g., GitHub, GitLab) and follow the prompts to authorize Snyk via OAuth 2.0. This process typically involves redirecting to your Git provider's site to grant permissions.
- SAML/SSO: For enterprise setups, an administrator will configure SAML/SSO within the Snyk organization settings, linking it to your corporate identity provider. This often involves exchanging metadata files between Snyk and your IdP. The Snyk documentation for configuring SSO provides specific steps.
Authenticated request example
When interacting with Snyk's developer tools, authentication often happens implicitly after an initial setup. For instance, using the Snyk CLI requires authenticating once, and subsequent commands use the stored token. Here's an example of how to authenticate the Snyk CLI and then run a scan, which leverages Deepcode's underlying technology:
Snyk CLI Authentication and Scan
First, install the Snyk CLI globally:
npm install -g snyk
Then, authenticate the CLI using your API token. Replace YOUR_SNYK_API_TOKEN with the token obtained from your Snyk account settings:
snyk auth YOUR_SNYK_API_TOKEN
Once authenticated, you can run a scan on a directory containing your source code. This command will analyze your project for vulnerabilities, including those identified by Snyk Code (Deepcode technology).
snyk code test --org=your-organization-id
The --org flag specifies the Snyk Organization under which the scan should be performed. You can find your organization ID in your Snyk dashboard URL or settings. The Snyk CLI automatically uses the authenticated token for this request. For more CLI commands and options, consult the Snyk CLI documentation.
HTTP API Request Example (using cURL)
For direct API interactions, your API token is typically passed in the Authorization header using the Token scheme.
curl --request GET \
--url "https://api.snyk.io/rest/orgs/{org_id}/projects?version=2024-05-29" \
--header "Authorization: Token YOUR_SNYK_API_TOKEN" \
--header "Content-Type: application/json"
Replace {org_id} with your Snyk organization ID and YOUR_SNYK_API_TOKEN with your actual API token. This example fetches a list of projects within a specified organization using the Snyk REST API. For details on the Snyk API, refer to the Snyk REST API documentation.
Security best practices
Securing your authentication credentials for Deepcode's integrated technology is crucial for protecting your code and data. Adhere to these best practices:
-
Treat API Tokens as Sensitive: Your Snyk API token grants significant access to your account and projects. Treat it with the same level of security as a password. Never embed tokens directly in source code, commit them to version control, or expose them in public logs.
-
Use Environment Variables: Store API tokens in environment variables for CI/CD pipelines and local development. This prevents them from being hardcoded and makes them easily manageable. For example, in a CI/CD system, configure a secret variable named
SNYK_TOKENand reference it in your build scripts. -
Leverage Secret Management Tools: For production environments and complex setups, use dedicated secret management services like HashiCorp Vault, AWS Secrets Manager, Google Cloud Secret Manager, or Azure Key Vault. These tools securely store, manage, and distribute sensitive credentials.
-
Implement Least Privilege: When generating API tokens or configuring integrations, grant only the minimum necessary permissions required for the task. Avoid using tokens with broad administrative access for automated systems that only need to perform specific read or scan operations.
-
Rotate API Tokens Regularly: Periodically rotate your API tokens, especially for automated systems. This reduces the window of exposure if a token is compromised. Snyk provides mechanisms to generate new tokens and revoke old ones through its web UI.
-
Monitor Access and Logs: Regularly review Snyk audit logs and access activity to detect any unusual or unauthorized use of your account and tokens. Implement alerts for suspicious activities if supported by your Snyk plan.
-
Secure Development Environment: Ensure that local development machines and build servers where Snyk CLI or integrations are used are themselves secure. This includes using strong passwords, enabling multi-factor authentication (MFA) for user accounts, and keeping systems patched.
-
Utilize OAuth 2.0 for Git Integrations: When connecting Snyk to Git repositories, always prefer OAuth 2.0 over direct credential input. OAuth provides delegated authorization, meaning Snyk accesses your repositories on your behalf without ever seeing your Git login credentials, enhancing security. The OAuth 2.0 protocol is a widely adopted standard for secure delegation.
-
Enforce SAML/SSO: For organizations, enforce SAML/SSO to centralize identity management. This allows your corporate identity provider to handle authentication, leveraging its security policies, including MFA, conditional access, and password complexity requirements. This is a critical security control for managing access to cloud services.
-
Educate Developers: Ensure all developers understand the importance of secure credential handling and the specific practices for using Snyk. Regular training can help prevent accidental exposure of tokens.