Access Tokens
Access tokens authenticate Composer clients with your Pricore instance. They provide secure, revocable access to your private packages.
Token Types
Pricore supports two types of tokens:
Organization Tokens
- Created by organization admins
- Can be scoped to specific packages
- Ideal for CI/CD pipelines and shared access
Personal Tokens
- Created by individual users
- Inherit the user's organization permissions
- Ideal for local development
Creating Tokens
Organization Token
- Navigate to Organization Settings > Access Tokens
- Click Create Token
- Enter a descriptive name (e.g., "CI Pipeline", "Production Deploy")
- Select scopes and package access
- Set an optional expiration date
- Click Create
- Copy the token immediately - it won't be shown again
Personal Token
- Go to Account Settings > Access Tokens
- Click Create Token
- Enter a name for the token
- Set an optional expiration date
- Click Create
- Copy and store the token securely
Token Scopes
| Scope | Permission |
|---|---|
packages:read | Download packages |
packages:write | Upload and modify packages |
packages:delete | Delete packages and versions |
Package-Level Access
Organization tokens can be restricted to specific packages:
- When creating a token, select Limit to specific packages
- Choose which packages this token can access
- The token will only work for selected packages
This is useful for:
- CI pipelines that only need access to certain packages
- Third-party integrations with minimal permissions
- Temporary access for contractors
Using Tokens with Composer
Global Configuration
Configure Composer globally to use your token:
bash
composer config --global --auth http-basic.packages.yourcompany.com token YOUR_ACCESS_TOKENThis creates or updates ~/.composer/auth.json:
json
{
"http-basic": {
"packages.yourcompany.com": {
"username": "token",
"password": "YOUR_ACCESS_TOKEN"
}
}
}Project Configuration
For project-specific tokens, create auth.json in your project root:
json
{
"http-basic": {
"packages.yourcompany.com": {
"username": "token",
"password": "YOUR_ACCESS_TOKEN"
}
}
}WARNING
Add auth.json to your .gitignore to avoid committing tokens to version control.
Environment Variables
For CI/CD, use environment variables:
bash
export COMPOSER_AUTH='{"http-basic":{"packages.yourcompany.com":{"username":"token","password":"'"$PRICORE_TOKEN"'"}}}'Or in your CI configuration:
yaml
# GitHub Actions example
- name: Configure Composer
run: |
composer config --global --auth http-basic.packages.yourcompany.com token ${{ secrets.PRICORE_TOKEN }}Token Security
Best Practices
- Use descriptive names - Know what each token is used for
- Set expiration dates - Rotate tokens regularly
- Minimize scope - Only grant necessary permissions
- Limit package access - Restrict tokens to required packages
- Never commit tokens - Use environment variables or secrets management
Revoking Tokens
To revoke a token:
- Go to the token list (Organization or Personal settings)
- Find the token to revoke
- Click Revoke
- Confirm the action
Revoked tokens immediately stop working. Update any systems using the token.
Token Audit
Monitor token usage:
- Last Used - When the token was last used
- Created - When the token was created
- Expires - When the token will expire (if set)
Regular audits help identify:
- Unused tokens that should be revoked
- Tokens used more frequently than expected
- Tokens approaching expiration
CI/CD Integration
GitHub Actions
yaml
name: Install Dependencies
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- name: Configure Pricore
run: composer config --global --auth http-basic.packages.yourcompany.com token ${{ secrets.PRICORE_TOKEN }}
- name: Install dependencies
run: composer installGitLab CI
yaml
install:
stage: build
before_script:
- composer config --global --auth http-basic.packages.yourcompany.com token $PRICORE_TOKEN
script:
- composer installBitbucket Pipelines
yaml
pipelines:
default:
- step:
script:
- composer config --global --auth http-basic.packages.yourcompany.com token $PRICORE_TOKEN
- composer installTroubleshooting
Authentication Failed
- Verify the token is correct (no extra spaces)
- Check that the token hasn't been revoked
- Ensure the token has appropriate scopes
- Verify the domain in
auth.jsonmatches your Pricore URL
Token Not Working for Specific Package
- Check package-level restrictions on the token
- Verify the organization membership
- Ensure the package exists and is accessible
Token Expired
- Check the token's expiration date
- Create a new token if expired
- Update all systems using the old token