Authentication & SSO
Configure Single Sign-On (SSO) with Google Workspace or Microsoft Entra ID
Supported Identity Providers
Junet supports two major identity providers:
- Google Workspace - For organizations using Google services
- Microsoft Entra ID - For organizations using Microsoft 365 / Azure
Configuring Google Workspace SSO
Prerequisites
- Google Workspace admin account
- Domain verified in Google Workspace
- Users must have Google Workspace accounts
Step 1: Access Google Cloud Console
- Go to Google Cloud Console
- Sign in with your Google Workspace admin account
- Select your project or create a new one
Step 2: Enable Required APIs
- Navigate to APIs & Services → Library
- Enable the following APIs:
- Google+ API (for user profile)
- Admin SDK API (for group sync)
- People API (for user information)
Step 3: Create OAuth 2.0 Credentials
-
Go to APIs & Services → Credentials
-
Click "Create Credentials" → "OAuth client ID"
-
Configure the consent screen if prompted:
- User Type: Internal (for Workspace) or External
- Application Name: "Junet"
- Scopes: Add required scopes (email, profile, groups)
-
Application Type: Web application
-
Name: "Junet SSO"
-
Authorized JavaScript origins:
https://your-junet-domain.com- Add your production URL
-
Authorized redirect URIs:
https://your-junet-domain.com/api/auth/callback/google- This is where Google redirects after authentication
-
Click "Create"
-
Save the credentials:
- Client ID
- Client Secret
Step 4: Configure in Junet
-
Navigate to Junet Admin Panel
- Admin → Application Settings → Authentication
-
Select "Google Workspace"
-
Enter Configuration:
- Client ID: Paste from Google Cloud Console
- Client Secret: Paste from Google Cloud Console
- Domain: Your Google Workspace domain (e.g.,
company.com)
-
Enable Group Sync (Optional):
- Toggle "Sync Groups from Google Workspace"
- This allows automatic group import and synchronization
-
Click "Save Configuration"
-
Test the Connection:
- Click "Test SSO Connection"
- You should be redirected to Google login
- Verify successful authentication
Google Workspace SSO Configured! Users can now sign in with their Google Workspace accounts.
Google Workspace Permissions
Junet requires the following OAuth scopes:
https://www.googleapis.com/auth/userinfo.email- Read user emailhttps://www.googleapis.com/auth/userinfo.profile- Read user profilehttps://www.googleapis.com/auth/admin.directory.group.readonly- Read groups (for group sync)https://www.googleapis.com/auth/admin.directory.user.readonly- Read user directory (for group membership)
Configuring Microsoft Entra ID (Azure AD) SSO
Prerequisites
- Microsoft Entra ID (Azure AD) tenant
- Global Administrator or Application Administrator role
- Users must have Entra ID accounts
Step 1: Register Application in Entra ID
-
Go to Azure Portal
-
Navigate to Microsoft Entra ID (formerly Azure Active Directory)
-
Select App registrations → New registration
-
Register Application:
- Name: "Junet SSO"
- Supported account types:
- "Accounts in this organizational directory only" (Single tenant)
- Redirect URI:
- Platform: Web
- URI:
https://your-junet-domain.com/api/auth/callback/entra
-
Click "Register"
-
Save the Application Details:
- Application (client) ID - You'll need this
- Directory (tenant) ID - You'll need this
Step 2: Create Client Secret
- In your app registration, go to Certificates & secrets
- Click "New client secret"
- Description: "Junet SSO Secret"
- Expires: Choose duration (24 months recommended)
- Click "Add"
- Copy the secret value immediately - It won't be shown again!
Step 3: Configure API Permissions
This is crucial for Junet to access user and group information.
-
Go to API permissions in your app registration
-
Click "Add a permission" → "Microsoft Graph"
-
Add the following permissions:
Permission 1: User.Read (Delegated)
- Type: Delegated
- Permission:
User.Read - Description: Sign in and read user profile
- Admin Consent Required: No
- Purpose: Allows users to sign in and Junet to read their profile
Permission 2: User.Read.All (Application)
- Type: Application
- Permission:
User.Read.All - Description: Read all users' full profiles
- Admin Consent Required: Yes
- Purpose: Allows Junet to read user directory for group membership and user provisioning
How to add:
- Click "Add a permission"
- Select "Microsoft Graph"
- Choose "Application permissions"
- Search for "User.Read.All"
- Check the box
- Click "Add permissions"
Permission 3: Group.Read.All (Application)
- Type: Application
- Permission:
Group.Read.All - Description: Read all groups
- Admin Consent Required: Yes
- Purpose: Allows Junet to read group information and membership for automatic group synchronization
How to add:
- Click "Add a permission"
- Select "Microsoft Graph"
- Choose "Application permissions"
- Search for "Group.Read.All"
- Check the box
- Click "Add permissions"
Step 4: Grant Admin Consent
Important: Application permissions require admin consent before they work.
After adding all permissions:
- Click "Grant admin consent for [Your Organization]"
- Confirm by clicking "Yes"
- Wait for the consent to be granted
- Verify all permissions show "Granted for Default Directory" in green
Permission Summary:
| Permission | Type | Admin Consent | Status | Purpose |
|---|---|---|---|---|
| User.Read | Delegated | No | ✅ Granted | User sign-in |
| User.Read.All | Application | Yes | ✅ Granted | Read user profiles |
| Group.Read.All | Application | Yes | ✅ Granted | Read groups & sync |
Step 5: Configure in Junet
-
Navigate to Junet Admin Panel
- Admin → Application Settings → Authentication
-
Select "Microsoft Entra ID"
-
Enter Configuration:
- Application (Client) ID: From Step 1
- Directory (Tenant) ID: From Step 1
- Client Secret: From Step 2
- Tenant Domain: Your organization's domain (e.g.,
company.com)
-
Enable Group Sync (Optional):
- Toggle "Sync Groups from Entra ID"
- This allows automatic group import and synchronization
- Requires
Group.Read.Allpermission
-
Click "Save Configuration"
-
Test the Connection:
- Click "Test SSO Connection"
- You should be redirected to Microsoft login
- Verify successful authentication
- Check that user information is retrieved correctly
Microsoft Entra ID SSO Configured! Users can now sign in with their Microsoft accounts.
Entra ID Permissions Explained
Why these specific permissions?
User.Read (Delegated):
- Allows individual users to sign in
- Reads basic profile (name, email)
- No admin consent needed
- User consents on first login
User.Read.All (Application):
- Required for automatic user provisioning
- Allows Junet to read all user profiles in your directory
- Needed to verify group membership
- Required for Just-in-Time (JIT) provisioning
- Requires admin consent
Group.Read.All (Application):
- Required for group synchronization
- Allows Junet to read group information
- Enables automatic group import from Entra ID
- Keeps group membership up-to-date
- Required for automatic permission management
- Requires admin consent
SSO Login Flow
How Users Sign In
- User navigates to Junet
- Clicks "Sign in with [Google/Microsoft]"
- Redirected to Identity Provider:
- Google Workspace login page
- Microsoft Entra ID login page
- User enters credentials (if not already signed in)
- Identity Provider verifies user
- User redirected back to Junet
- Junet creates or updates user account:
- Profile information synced
- Group memberships synced (if enabled)
- Permissions applied based on groups
- User accesses Junet chat interface
First-Time Login
When a user logs in for the first time via SSO:
-
Account Auto-Creation:
- User account created automatically in Junet
- Profile populated from IDP (name, email, photo)
- No manual user creation needed
-
Group Assignment:
- If group sync is enabled:
- User's IDP groups are checked
- Matching Junet groups are assigned
- Permissions applied immediately
- If group sync is enabled:
-
Welcome Experience:
- User sees welcome message
- Guided through available agents
- Can start chatting immediately
Group Synchronization
When SSO is enabled with group sync, Junet automatically:
What Gets Synced
From Google Workspace:
- All groups the user belongs to
- Group names and descriptions
- Nested group membership
- Updates every 15 minutes
From Entra ID:
- Security groups
- Microsoft 365 groups
- Nested group membership
- Group metadata
- Updates every 15 minutes
How to Use Synced Groups
-
Import Groups:
- Admin Panel → User Management → Groups
- Click "Import Group from IDP"
- Select groups to import
- Configure Junet-specific permissions
-
Automatic Membership:
- When users sign in, their group memberships sync automatically
- Changes in IDP reflect in Junet within 15 minutes
- No manual user assignment needed
-
Manage Permissions:
- Configure agent access per group
- Configure connection access per group
- Users inherit permissions from all their groups
Troubleshooting
Google Workspace SSO Issues
Error: "redirect_uri_mismatch"
Cause: Redirect URI in Google Cloud Console doesn't match Junet's callback URL
Solution:
- Go to Google Cloud Console → Credentials
- Edit OAuth 2.0 Client ID
- Add exact redirect URI:
https://your-domain.com/api/auth/callback/google - Include both HTTP and HTTPS if testing locally
Error: "access_denied"
Cause: User doesn't have permission or app needs verification
Solution:
- Verify user is in your Google Workspace domain
- Check OAuth consent screen configuration
- Ensure app is set to "Internal" for Workspace users
- Complete app verification if using "External"
Groups Not Syncing
Cause: Missing Admin SDK API permissions
Solution:
- Enable Admin SDK API in Google Cloud Console
- Ensure service account has domain-wide delegation
- Grant required scopes in Workspace Admin console
Entra ID SSO Issues
Error: "invalid_client"
Cause: Client ID or Client Secret is incorrect
Solution:
- Verify Client ID in Junet matches Azure App Registration
- Check Client Secret hasn't expired
- Generate new secret if needed
- Update Junet configuration
Error: "unauthorized_client"
Cause: Redirect URI mismatch or app not authorized
Solution:
- Check redirect URI in Azure App Registration
- Verify it matches:
https://your-domain.com/api/auth/callback/entra - Ensure URL is exact (including https, no trailing slash)
Error: "AADSTS65001: The user or administrator has not consented"
Cause: Required permissions not granted by admin
Solution:
- Go to Azure Portal → App registrations
- Select your Junet app
- Go to API permissions
- Click "Grant admin consent for [Organization]"
- Confirm the action
Groups Not Syncing
Cause: Group.Read.All permission not granted or not consented
Solution:
- Verify
Group.Read.Allpermission is added - Ensure it's an Application permission (not Delegated)
- Click "Grant admin consent"
- Wait a few minutes for consent to propagate
- Test connection in Junet
Users Can't Sign In
Cause: Various possible issues
Solution Checklist:
- ✅ Verify users exist in Entra ID
- ✅ Check users are not blocked
- ✅ Verify all permissions are granted
- ✅ Check redirect URI is correct
- ✅ Test with admin account first
- ✅ Review Azure AD sign-in logs
Testing SSO Configuration
Step-by-step testing:
-
Test with Admin Account First:
- Reduces permission issues
- Confirms basic flow works
- Can troubleshoot easier
-
Check Network Tab:
- Open browser DevTools
- Monitor network requests
- Look for 401/403 errors
- Check redirect chains
-
Review Logs:
- Google: Check Admin console logs
- Azure: Check Entra ID sign-in logs
-
Test Different Users:
- Test with regular user (non-admin)
- Test with user in different groups
- Verify permissions are correct