Service Accounts
Service accounts are specialized user accounts designed for machine-to-machine authentication and automation purposes rather than interactive human use. They're ideal for integrating authentik with external systems, APIs, and services.
Types of Service Accounts
authentik distinguishes between two types of service accounts:
- User-created Service Accounts: Created by administrators for integrating with external systems or for automation purposes.
- Internal Service Accounts: Created and managed automatically by authentik for internal purposes, such as outpost communications. These cannot be created manually.
Limitations
Service accounts have certain limitations compared to regular user accounts:
- Cannot log in through the UI.
- Cannot have a password (they use tokens exclusively).
- Cannot participate in multi-factor authentication flows.
- Cannot be used for interactive sessions that require human interaction.
- Cannot have permissions assigned directly if they are internal service accounts.
- Cannot change their own password or manage their own account settings.
- Are subject to token expiration policies that differ from regular user accounts.
Creating a Service Account
To create a service account:
- In the authentik Admin interface, navigate to Directory > Users.
- Click the Create Service Account button.
- Configure the following settings:
- Username: The user's primary identifier (150 characters or fewer).
- Create Group: Enabling this toggle will create a group named after the user, with the user as a member.
- Expiring: If selected, the token will expire and be automatically rotated upon expiration.
- Expires on: Sets the expiration date (defaults to 1 year from the creation date).
- Click Create Service Account.
After creating the service account, you'll see a confirmation screen that shows the username and generated password (token). Make sure to copy this information somewhere secure as you'll need it for authentication.
Token Properties
Service account tokens have the following properties:
- Expiration: By default, tokens expire after 360 days but can be configured to be non-expiring.
- Custom Expiration Date: You can set a specific expiration date when creating the service account.
- Revocation: Tokens can be revoked at any time by deleting them or generating new ones.
- Automatic Rotation: When a token expires, it's automatically rotated to maintain security.
Managing Service Account Tokens
Tokens for service accounts are managed through the authentik Admin interface:
- Log in to the Admin interface and navigate to Directory > Tokens and App passwords.
- Here you can view, create, copy, delete, and manage tokens.
Creating New Tokens
To create a new token for a service account:
- Click Create.
- Set the identifier for your token.
- In the User dropdown list, select your service account.
- For Intent, choose one of the following:
- API Token: Used to access the API programmatically (30-minute default lifespan).
- App password: Used for logging in using a flow executor (1-year default lifespan).
- Click Create to generate the new token.
Managing and Regenerating Tokens
- To copy a token's value, use the copy button under the Actions column.
- To delete a token, select it from the list and click the Delete button.
- To regenerate a token, delete the existing token and create a new one with the same settings, ensuring you select the same username under the User dropdown list.
Authentication with Service Accounts
Service accounts authenticate using HTTP Basic Authentication. The username and password (token) generated during account creation are used as credentials.
Permissions and Access Control
Like regular user accounts, with service accounts you can assign permissions and use RBAC.
- Assign the service account to groups to inherit group permissions.
- Grant specific permissions directly to the service account.
- Restrict the service account to specific applications or resources.
We recommend following the principle of least privilege and only grant service accounts the permissions they absolutely need.
Common Use Cases
Integration with External Systems
Service accounts are commonly used for:
- LDAP Authentication: Systems like SSSD, QNAP NAS, and other LDAP clients often use service accounts to bind to authentik's LDAP provider.
- Directory Synchronization: Tools that sync users and groups between authentik and other systems.
- API Automation: For scripts, CI/CD pipelines, or other systems that need to interact with authentik's API.
Security Best Practices
When using service accounts, follow these security practices:
- Least Privilege: Grant service accounts only the permissions they need.
- Secure Storage: Store service account tokens securely in encrypted storage, environment variables, or secret management systems.
- Token Rotation: Rotate tokens periodically for sensitive integrations.
- Use Expiration: Set appropriate token expiration dates for your use case.
- Audit Usage: Monitor service account activity for unexpected behavior.