Overview
Macondo Link Manager uses Google OAuth 2.0 for secure authentication, ensuring that only authorized users from specific domains can access the platform. Authentication is cookie-based using JWT tokens, providing a seamless and secure experience.Google OAuth
Single sign-on with Google accounts
Domain Restriction
Only approved email domains allowed
JWT Tokens
Secure cookie-based sessions
7-Day Sessions
Long-lived authentication cookies
How Authentication Works
The authentication flow follows OAuth 2.0 standards with additional domain verification:Domain verification
After successful Google authentication, the system verifies your email domain against the allowed list
Account creation or login
If your domain is approved, the system either creates a new account or logs you into your existing account
Domain Restriction
Macondo Link Manager restricts access to specific email domains to ensure only authorized organization members can use the platform.Allowed Domains
By default, the following domains are permitted:macondopropaganda.commacondo.com.uy
Domain Validation Process
The system extracts the domain from your Google email address and checks it against the allowed domains list. This happens after Google authentication but before account creation.JWT Cookie Mechanism
Authentication tokens are stored as secure HTTP-only cookies, providing protection against XSS attacks while maintaining user sessions.Cookie Properties
| Property | Value | Description |
|---|---|---|
| Name | macondo.token | Cookie identifier |
| Max Age | 7 days | Token expiration time |
| HTTP Only | true | Prevents JavaScript access |
| Secure | true | Requires HTTPS connection |
| SameSite | none | Allows cross-site requests |
| Path | / | Valid for entire application |
Token Contents
The JWT payload includes essential user information:The
sub (subject) field contains the user’s unique identifier and is used throughout the application to associate resources with users.Login Flow
Starting Authentication
To begin the authentication process, users navigate to:OAuth Scopes
The application requests the following Google OAuth scopes:email- Access to user’s email addressprofile- Access to basic profile information (name, picture)
Callback Handling
After Google authentication, users are redirected to:- Exchanges the authorization code for an access token
- Fetches user information from Google’s API
- Validates the email domain
- Creates or retrieves the user account
- Generates a JWT token
- Sets the authentication cookie
- Redirects to the frontend application
Logout
Users can log out by sending a POST request to the logout endpoint:Logout Process
Response Example
Security Features
HTTP-Only Cookies
Prevents XSS attacks by making tokens inaccessible to JavaScript
Secure Flag
Requires HTTPS, preventing token transmission over insecure connections
Domain Whitelist
Restricts access to approved organizational domains only
Token Expiration
7-day token lifetime ensures regular re-authentication
Error Handling
Domain Not Allowed
When a user from a non-approved domain attempts to log in:Authentication Failures
For unexpected errors during authentication:- The error is logged on the server with full details
- The user receives a generic error message
- No sensitive information is exposed to the client
Protected Routes
Once authenticated, the JWT token is automatically included in requests via the cookie. Protected API endpoints verify the token using theauthHook middleware.
Automatic Token Verification
All routes marked withonRequest: [authHook] require valid authentication:
/links/*- Link management/clients/*- Client management/campaigns/*- Campaign management/dashboard/*- Analytics and dashboards
If a token is expired or invalid, the server returns a 401 Unauthorized response, prompting the user to log in again.
