Configure LinkedIn OAuth SSO for WireGuard
How to set up LinkedIn OAuth/OIDC single sign-on (SSO) for Wiretastix WireGuard VPN authentication.
This guide will walk you through configuring LinkedIn OAuth/OIDC as your Identity Provider for Wiretastix, enabling single sign-on (SSO) so users authenticate with their LinkedIn accounts.
Prerequisites
Before you begin, ensure you have:
- A LinkedIn account (personal or company account)
- Access to the LinkedIn Developers Portal
- Your Wiretastix instance URL (e.g.,
https://vpn.example.com) - Administrative access to your Wiretastix configuration
Important Note: LinkedIn’s OAuth 2.0 implementation has some differences from standard OpenID Connect. This guide covers the setup process, but be aware of LinkedIn’s specific limitations.
Step 1: Create a LinkedIn App
- Navigate to the LinkedIn Developers Portal
- Click Create app
- Fill in the required information:
- App name:
Wiretastix VPN(or your preferred name) - LinkedIn Page: Select your company’s LinkedIn page (you must be an admin of the page)
- If you don’t have a company page, you’ll need to create one first
- App logo: Upload your organization’s logo (optional but recommended)
- Legal agreement: Check the box to agree to LinkedIn’s API Terms of Use
- App name:
- Click Create app
Step 2: Configure App Settings
After creating the app, you’ll be taken to the app settings page:
On the Settings tab, note your:
- Client ID: You’ll need this for Wiretastix configuration
- Client Secret: Click Show and copy this value (keep it secure)
Scroll down to Redirect URLs (also called Authorized redirect URLs for your app)
Click the Edit icon (pencil)
Add your Wiretastix callback URL:
https://vpn.example.com/callbackReplace
vpn.example.comwith your actual Wiretastix domainClick Update
Step 3: Request API Access
LinkedIn requires you to request access to specific API products:
- Click on the Products tab in your app settings
- Find Sign In with LinkedIn using OpenID Connect
- Click Request access
- Fill in the required information about why you need access
- Submit the request
Note: LinkedIn typically reviews access requests within a few business days. For development and testing, you can proceed with the limited default access.
Step 4: Verify App Settings
Before configuring Wiretastix, verify the following on the Settings tab:
- Application Status: Should show as “Active” or “In Development”
- Redirect URLs: Verify your callback URL is listed
- Client ID and Secret: Ensure you have both values saved
Step 5: Configure Wiretastix
Edit your /etc/wiretastix/wiretastix.yaml file to configure LinkedIn as the OIDC provider:
oidc:
name: LinkedIn
client-id: YOUR_LINKEDIN_CLIENT_ID
client-secret: YOUR_LINKEDIN_CLIENT_SECRET
redirect-url: https://vpn.example.com/callback
config-issuer: https://www.linkedin.com/oauth/.well-known/openid-configuration
cookie-secret: GENERATE_A_RANDOM_STRING_HERE
force-approval: false
verbose: false
refresh-min-interval-sec: 300
scopes:
- openid
- profile
- email
constraints:
email:
- user1@example.com
- user2@example.com
Configuration Parameters Explained
name: A friendly name for the provider (displayed in logs)client-id: The Client ID from your LinkedIn appclient-secret: The Client Secret from your LinkedIn appredirect-url: Must match exactly what you configured in LinkedIn app settingsconfig-issuer: LinkedIn’s OpenID Connect discovery endpointcookie-secret: A random string for session encryption (generate with:openssl rand -base64 32)force-approval: Set totrueto force consent screen on every login (usuallyfalse)verbose: Enable detailed OIDC logging for troubleshootingrefresh-min-interval-sec: Minimum seconds between token refresh attemptsscopes: Required OAuth scopes for LinkedInconstraints: Access control rules
Understanding LinkedIn Scopes
LinkedIn supports the following OpenID Connect scopes:
openid: Required - Enables OpenID Connect authenticationprofile: Provides access to basic profile information (name, picture)email: Provides access to the user’s primary email address
Important: To access the email scope, your app must have been granted access to “Sign In with LinkedIn using OpenID Connect” in the Products tab.
Understanding Constraints
LinkedIn does not provide group or organization membership in OIDC claims. You must use email-based constraints:
constraints:
email:
- alice@example.com
- bob@example.com
- team@example.com
Limitation: LinkedIn does not support group-based access control through OIDC. You’ll need to:
- Use email constraints to control access
- Manually assign users to groups in Wiretastix after their first login
- Configure a
default_groupin Wiretastix to automatically assign authenticated users
Step 6: Generate a Cookie Secret
Generate a secure random string for the cookie-secret parameter:
openssl rand -base64 32
Copy the output and paste it into the cookie-secret field in your configuration.
Step 7: Restart Wiretastix
After updating the configuration, restart the Wiretastix daemon:
sudo systemctl restart wiretastix
Or if running manually:
sudo wiretastix-daemon -c /etc/wiretastix/wiretastix.yaml
Step 8: Test the Integration
- Open your web browser and navigate to your Wiretastix URL (e.g.,
https://vpn.example.com) - You should be redirected to LinkedIn’s sign-in page
- Sign in with a LinkedIn account whose email matches your constraints
- If this is the first time, you’ll see the LinkedIn authorization screen:
- Review the permissions being requested
- Click Allow to grant access
- You should be redirected back to Wiretastix and logged in
If successful, you’ll see the Wiretastix dashboard where you can create VPN devices.
Troubleshooting
Error: “redirect_uri_mismatch”
Cause: The redirect URL in your Wiretastix configuration doesn’t match what’s configured in LinkedIn.
Solution:
- Go to your LinkedIn app Settings → Auth section
- Verify the redirect URL exactly matches your
redirect-urlinwiretastix.yaml - Ensure there are no trailing slashes or protocol mismatches (http vs https)
- Click Update after making changes
- Restart Wiretastix and try again
Error: “access_denied”
Cause: The user declined authorization or their email is not in the constraints list.
Solutions:
- Ensure the user clicks Allow on the LinkedIn authorization screen
- Verify the user’s email address is in the
constraints.emaillist - Check that the user’s email is verified on their LinkedIn account
Error: “invalid_scope” or Scope Not Available
Cause: Your app doesn’t have access to the requested scope (typically email).
Solutions:
- Go to your LinkedIn app’s Products tab
- Verify you’ve requested “Sign In with LinkedIn using OpenID Connect”
- Wait for approval if the request is pending
- For testing, you may need to use test accounts or request expedited review
Email Not Returned by LinkedIn
Cause: The email scope requires special access from LinkedIn.
Solutions:
- Ensure you’ve been granted access to “Sign In with LinkedIn using OpenID Connect”
- Check that
emailis in your scopes list - During development, use the primary email associated with your test accounts
- Consider implementing fallback logic to use LinkedIn ID instead of email
Token Refresh Issues
Cause: LinkedIn’s refresh token behavior differs from other providers.
Solutions:
- LinkedIn’s refresh token lifetime is long compared to most providers (check the current value for your app in the LinkedIn Developer Portal, since it isn’t uniform across API products and can change)
- Set a longer
refresh-min-interval-secvalue (e.g., 3600 = 1 hour) - Consider running
config set auto_disable_on_auth_error 0(a CLI runtime parameter, not awiretastix.yamlfield) to prevent automatic user disablement
Enable Verbose Logging
For troubleshooting, enable verbose OIDC logging:
oidc:
verbose: true
Restart Wiretastix and check the logs:
sudo journalctl -u wiretastix -f
LinkedIn-Specific Considerations
API Rate Limits
LinkedIn enforces rate limits on their APIs:
- Be mindful of token refresh frequency
- Increase
refresh-min-interval-secto reduce API calls - Monitor your app’s usage in the LinkedIn Developer Portal
Limited User Data
LinkedIn provides limited user information compared to other OIDC providers:
- No group memberships
- No organization roles
- Basic profile data (name, email, picture)
User Verification
LinkedIn users must have verified email addresses to authenticate:
- Unverified accounts may not return email claims
- Direct users to verify their email on LinkedIn before attempting to authenticate
Production Access
For production use:
- Complete the LinkedIn app verification process
- Ensure your app complies with LinkedIn’s terms of service
- Request production access for all required scopes
- Add clear privacy policy and terms of service links
Testing with LinkedIn Test Accounts
During development, you can test with LinkedIn accounts that are administrators of your LinkedIn page:
- Go to your app’s Settings tab
- Scroll to App Settings
- Admins of the associated LinkedIn page can test authentication before approval
Security Best Practices
- Use HTTPS: Always use HTTPS for your Wiretastix instance
- Restrict Email Access: Only add authorized users to the
constraints.emaillist - Secure Credentials: Keep your client secret confidential
- Secure Cookie Secret: Generate a strong random cookie secret
- Monitor Access: Regularly review authentication logs
- Token Storage: LinkedIn tokens are stored encrypted by Wiretastix
- Limit Scope: Only request the scopes you actually need
Limitations and Alternatives
LinkedIn Limitations
- No group-based access control
- Limited to email-based user identification
- Requires app verification for production use
- API rate limits may affect large deployments
Alternative Approaches
If LinkedIn’s limitations are problematic, consider:
- Using LinkedIn as secondary authentication: Combine with another IdP for group management
- Manual group assignment: Assign users to Wiretastix groups after first login
- Alternative IdP: Use a more feature-rich OIDC provider like Authentik or Keycloak
Next Steps
After successfully configuring LinkedIn OIDC:
- Manage Users - Review authenticated users
- Manage Groups - Configure group policies (membership itself comes from LinkedIn’s claims, not manual assignment)
- Configure Network Rules - Set up firewall rules
- Default Configuration Settings - Configure default groups and policies