Essential Auth Service

The single sign-on identity layer for every Essential Nigeria product

https://auth.edirect.ng

Overview

Essential Auth is the single identity system for the Essential group. One account, one password, and one profile — usable across every Essential platform (ecars, eproperties, edirect, ejobs, emedicals, and dozens more). Your project authenticates users here, and gets verified identity data back in exchange.

There are two ways to integrate:

ApproachWhen to useEffort
A. Central SSOWeb apps, mobile apps, SPAs we build/control. Recommended for all internal products.30–60 minutes
B. OAuth 2.0Public apps, or a standard "Sign in with Essential Auth" button.Requires OAuth client + scopes
Note: All requests go to the API under /api/..., all responses are JSON, and all protected endpoints use Authorization: Bearer TOKEN. The human login page (for flow A) lives at https://auth-front.edirect.ng/login.

Getting Started

1. Your platform must be registered

Before users can log in, the auth service must recognise your platform code and the exact redirect URI it will return to after login. This allowlist is enforced centrally and fails closed — an unknown platform, or a URI not on the list, gets 403 Redirect URI is not allowed.

If your project is already in the system

You're all set — just use your platform code (e.g. eproperties, ecars). A current list of registered client platform codes: ecars, prideofnigeria, prideoftheworld, eproperties, edirect, esupport, edrive, elogistics, ejob, edrivers, expense-tracker, ejobs, joblink, joblink-voucher, interviewsessioncall, privatestaff, eservices, momogram, epolls, fastoffer, emedicals, emedicals-hrm, emessenger, essentialnews, essentialgroup, autograph, evenue, eroot, ewallet, evideo, eaccademy, momogram-eroot, fundpal, esecurity, ebooks, ebenefit, ewish, eauction, eschoolconnect, eschoolconnect-med, ewish-eschoolconnect, ereligion, efixit, estores, ereport, elegal, hoteljobs, ehotels, ehotels-inventory, whoiswho, ewish-tests.

If your platform is NOT in the system

You need your platform added before any developer can integrate. Do one of:

  1. Contact the Essential DevOps / platform admin — they create your platform in the e-auth admin project (an internal dashboard + API) and add your redirect URI to the allowlist. Give them your platform name and your production callback URL.
  2. If you maintain the auth repository yourself, add your entry to config/sso.php (see below) and create your Platform record via the admin API.

The admin creates/documents Platform records like this (DevOps only — protected by an admin role):

POST https://auth.edirect.ng/api/admin/platforms
{
  "platform_name": "My Great Product",
  "platform_url": "https://myproduct.com",
  "description": "What my product does",
  "webhook_url": "https://myproduct.com/webhooks",
  "default_commission_rate": 10,
  "default_points_rate": 100,
  "is_active": true
}
{
  "success": true,
  "message": "Platform created successfully. Please save the API key and webhook secret securely as they won't be shown again.",
  "platform": {
    "id": 1,
    "platform_code": "my_great_product",
    "api_key": "pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "webhook_secret": "whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    ...
  }
}
Save your credentials — api_key (used on platform-to-platform APIs) and webhook_secret (used to sign webhook payloads) are shown once at creation and then hidden. They can be regenerated by an admin if lost.

The allowlist: config/sso.php

Redirect URIs are declared per environment (local, staging, production) and matched exactly (a trailing slash is ignored, but prefixes are never accepted):

return [
    'clients' => [
        'eproperties' => [
            'redirect_uris' => [
                'local'       => ['http://eproperties.test/auth/e-auth/callback'],
                'staging'     => ['https://staging.eproperties.com/auth/e-auth/callback'],
                'production'  => ['https://eproperties.com/auth/e-auth/callback'],
            ],
        ],
        // ... add your platform here ...
    ],
];

The same platform code must be used for the allowlist entry, the platform field you send to the API, and the platform your users are created under.

A. Central SSO — Full Integration Guide

Works for web, mobile, or SPA. Your users get one identity across every Essential platform. A user who signs up on eproperties today can sign in on edirect tomorrow with the same email and password.

The complete flow

  1. Your server calls /api/auth/sso/initiate → receives a redirect_url.
  2. Browser is redirected to the auth login page with an auth_code. The user logs in or registers.
  3. Auth service verifies credentials, issues a session_token, and redirects the browser back to your redirect_uri with ?session_token=...&state=....
  4. Your server verifies the session_token with /api/auth/verify-sso-token and receives the verified user profile + a JWT for the auth API.
  5. Your app signs the user in locally (mint your own session/JWT from the verified identity).

Step 1 — Initiate the flow

POST https://auth.edirect.ng/api/auth/sso/initiate

Headers: Content-Type: application/json

{
  "platform": "eproperties",
  "redirect_uri": "http://eproperties.test/auth/e-auth/callback",
  "state": "random_csrf_token_abc123"
}

platform must be registered. redirect_uri must exactly match an allowed URI for the current environment. state is optional but strongly recommended to bind each attempt to your session.

curl -X POST https://auth.edirect.ng/api/auth/sso/initiate \
  -H "Content-Type: application/json" \
  -d '{"platform":"eproperties","redirect_uri":"http://eproperties.test/auth/e-auth/callback","state":"abc123"}'

Success (200):

{
  "redirect_url": "http://e-auth.test/login?auth_code=AbCdEf123456...&platform=eproperties&redirect_uri=http%3A%2F%2Feproperties.test%2Fauth%2Fe-auth%2Fcallback&state=abc123"
}

Failures: 422 invalid/missing fields · 403 platform unknown or redirect_uri not allowed · 500 auth login page not configured.

Step 2 — Redirect the user

Send the browser to redirect_url (302 redirect server-side, or window.location in a webview/SPA). On the auth login page the user signs in (or switches to Register and creates an account). The login page never trusts a redirect_uri submitted by the browser — it always uses the one tied to the auth_code, which makes tampering impossible.

Good to know: the auth_code is single-use and expires in 10 minutes. If it's used or expired you'll get 401 Invalid or expired authorization code — just start a fresh initiate.

Step 3 — Complete the login (exchange auth code)

POST https://auth.edirect.ng/api/auth/sso/login

Your backend calls this immediately after the initiate step (or when your app restores the flow). Two options:

Option 1 — The user's browser did the login/register on the auth page (most common). You tell the API you trust the auth_code and claim a session:

{
  "auth_code": "AbCdEf123456...",
  "platform": "eproperties"
}

Option 2 — You already hold the user's credentials on your side. The API logs the user in as part of the exchange:

{
  "auth_code": "AbCdEf123456...",
  "platform": "eproperties",
  "email": "user@example.com",
  "password": "their_password"
}

Option 3 — The user already has an auth JWT from a previous session. Send it as a Bearer token: Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9... with a body like Option 1.

Success (200):

{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
  "session_token": "9f2c8d0a1b3c...",
  "redirect_uri": "http://eproperties.test/auth/e-auth/callback",
  "message": "SSO Login successful",
  "user": {
    "id": 4,
    "userId": "...", "user_id": "...",
    "platform": "eproperties",
    "platform_user_id": "EPROPERTIES-1A2B3C4D",
    "platform_role": "user",
    "is_primary_account": true,
    "primary_user_id": null,
    "name": "Jane Doe", "first_name": "Jane", "last_name": "Doe",
    "email": "jane@example.com", "phone": "+2348000000000",
    "role": "user",
    "referral_code": "...", "team_id": "...", "team_name": "..."
  },
  "platform": "eproperties",
  "platform_role": "user",
  "is_new_platform_account": false
}

What you get:

The auth_code is consumed by this call, so call it only once. Then send the browser to:

http://eproperties.test/auth/e-auth/callback?session_token=9f2c8d0a1b3c...&state=abc123
Security: the browser redirect above must be treated as unverified. Never log a user in based on the URL alone. Verify state matches what you sent in Step 1, then validate the session_token server-side in Step 4 before trusting the identity.

Step 4 — Verify the session token (server-side)

POST https://auth.edirect.ng/api/auth/verify-sso-token
{
  "token": "9f2c8d0a1b3c...",
  "platform": "eproperties"
}
curl -X POST https://auth.edirect.ng/api/auth/verify-sso-token \
  -H "Content-Type: application/json" \
  -d '{"token":"9f2c8d0a1b3c...","platform":"eproperties"}'

Success (200):

{
  "user": {
    "id": 4,
    "name": "Jane Doe",
    "first_name": "Jane",
    "last_name": "Doe",
    "email": "jane@example.com",
    "phone": "+2348000000000",
    "platform": "eproperties",
    "role": "user"
  },
  "api_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}

Failures: 401 Invalid SSO token · 404 user no longer exists. This returns the canonical profile (name, first_name, last_name, email, phone) — use it to create or update the user on your side.

Step 5 — Sign the user in on your platform

With the verified profile in hand, create your local user (or match by email) and mint your own session or JWT using your secret. Do not accept the auth JWT as your own — each product signs its own tokens.

Worked example (eproperties — Laravel)

This is the exact pattern deployed in eproperties. It uses illuminate/http (Laravel HTTP client) with the auth service's base URL and platform code in config:

// config/api.php
'eauth_enabled'  => env('EAUTH_SSO_ENABLED', false),
'eauth_url'      => env('EAUTH_URL', 'http://e-auth.test'),
'eauth_platform' => env('EAUTH_PLATFORM', 'eproperties'),

// routes/web.php
Route::get('/auth/e-auth', [EAuthSsoController::class, 'redirect'])->name('eauth.redirect');
Route::get('/auth/e-auth/callback', [EAuthSsoController::class, 'callback'])->name('eauth.callback');
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;

class EAuthSsoController extends Controller
{
    public function redirect()
    {
        $state = Str::random(32);
        session(['eauth_state' => $state]);

        // Step 1: initiate
        $res = Http::post(config('api.eauth_url') . '/api/auth/sso/initiate', [
            'platform'     => config('api.eauth_platform'),
            'redirect_uri' => route('eauth.callback'),
            'state'        => $state,
        ]);

        if ($res->status() !== 200) {
            return back()->with('error', 'SSO start failed: ' . $res->json('error'));
        }

        // Step 2: send the user to the auth login page
        return redirect($res->json('redirect_url'));
    }

    public function callback(Request $request)
    {
        // Step 4 (guard first): state must match, session_token must be present
        if (! hash_equals(session('eauth_state'), (string) $request->query('state'))
            || ! $request->has('session_token')) {
            return redirect()->route('login')->with('error', 'SSO verification failed.');
        }

        $verify = Http::post(config('api.eauth_url') . '/api/auth/verify-sso-token', [
            'token'    => $request->query('session_token'),
            'platform' => config('api.eauth_platform'),
        ]);

        if ($verify->status() !== 200) {
            return redirect()->route('login')->with('error', 'SSO verification failed.');
        }

        $identity = $verify->json('user');

        // Step 5: upsert the user in YOUR database and log them in locally.
        // Your LoginController must accept a $provider Verified identity
        // ($identity['email'], $identity['first_name'], $identity['last_name']),
        // auto-provisioning when the user doesn't exist yet.
        return $this->loginWithProvider($identity);
    }
}

And the button on the login page (rendered only when the feature is enabled):

That's the whole integration. Initiate → redirect → verify → sign in locally. No callbacks, no secrets to rotate, no per-user provisioning required.

B. OAuth 2.0 — "Sign in with Essential Auth"

Standard OAuth 2.0 Authorization Code flow (Laravel Passport) for public apps or when you specifically need standard OAuth. Requires registering an OAuth client first.

Step 1 — Register an OAuth client

Step 2 — Start authorization

https://auth.edirect.ng/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_CALLBACK_URL&response_type=code&scope=&state=RANDOM_STATE
ParamRequiredDescription
client_idYesYour OAuth client ID
redirect_uriYesMust match the registered redirect URI
response_typeYescode
scopeNoComma-separated scopes, or empty
stateRecommendedCSRF protection token

Step 3 — Exchange the code for tokens

curl -X POST https://auth.edirect.ng/oauth/token \
  -H "Content-Type: application/json" \
  -d '{
    "grant_type": "authorization_code",
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "redirect_uri": "YOUR_CALLBACK_URL",
    "code": "AUTHORIZATION_CODE"
  }'
{
  "token_type": "Bearer",
  "expires_in": 31536000,
  "access_token": "OAUTH_ACCESS_TOKEN",
  "refresh_token": "REFRESH_TOKEN"
}

Step 4 — Access user data

curl https://auth.edirect.ng/api/auth/user/data \
  -H "Authorization: Bearer OAUTH_ACCESS_TOKEN"

Direct Register & Login (without the redirect)

For mobile apps or backend-to-backend flows where you already hold credentials. Same identity system — the user's account is still primary/linked and usable everywhere else.

Register

POST https://auth.edirect.ng/api/auth/register
{
  "first_name": "Jane",
  "last_name": "Doe",
  "email": "jane@example.com",
  "password": "Password123",
  "password_confirmation": "Password123",
  "platform": "eproperties",
  "phone": "+2348000000000"
}

Success (201) — profile, team, referral code/URL, wallet and virtual account (when provisioned):

{
  "message": "Registration successful on eproperties.",
  "user": { "id": 5, "email": "jane@example.com", "platform": "eproperties", "platform_role": "user", "is_primary_account": true, ... },
  "team": { "id": 12, "name": "..." },
  "referral": { "code": "ABC123", "url": "https://...", "platform": "eproperties", "referred_by": null },
  "wallet": { "customer_code": "CUS_...", "wallet_id": "wlt_...", "synced_at": "2026-10-07 09:00:00" },
  "virtual_account": null
}
Registration is rate-limited and, on modern platforms, triggered by the SSO flow itself (Option 2 in Step 3 above auto-creates the account). You normally don't call register separately — see FAQ 1.

Login

POST https://auth.edirect.ng/api/auth/login
{
  "email": "jane@example.com",
  "password": "Password123",
  "platform": "eproperties"
}

Success (200): { "message": "Login successful", "token": "...", "user": {...} }. Use Authorization: Bearer TOKEN for authenticated calls.

Email verification & password

Endpoint Reference

Auth (public)

MethodEndpointDescription
POST/api/auth/sso/initiateStart Central SSO; returns redirect_url
POST/api/auth/sso/loginComplete Central SSO (exchange auth_code)
POST/api/auth/verify-sso-tokenVerify a session_token and return the user profile
GET/api/auth/check-sso-sessionSession check page used by the login form (one-time 5-min token)
POST/api/auth/registerRegister a user on a platform
POST/api/auth/loginDirect login (throttled)
GET/api/auth/verify-emailVerify email (token query param)
POST/api/auth/email/resendResend verification email
POST/api/auth/password/confirmConfirm current password
POST/api/auth/password/reset-requestRequest password reset
POST/api/auth/password/resetReset password
POST/api/auth/auto-loginCode-based auto login
GET/api/auth/verify/login/codeVerify auto-login code
GET/api/check-sessionCheck session status
GET/api/user/platformsPlatforms available to a user (email/phone)

Auth (Bearer token required)

MethodEndpointDescription
GET/api/auth/user/dataCurrent authenticated user
POST/api/logoutLogout (revoke session)
POST/api/change-passwordChange password
PUT/api/platform/roleUpdate the user's role on a platform

Users & federated search

MethodEndpointDescription
GET/api/users/search?q=...&platform=...Federated user search (used by eDirect AdeSearch)
GET/api/users/{identifier}Profile lookup by platform_user_id, referral code, or id

Webhooks (platform-to-platform)

MethodEndpointDescription
POST/api/webhooks/{platformCode}Ingest an event for a platform (authenticated with that platform's webhook secret)

Commission & points (platform-to-platform — X-API-Key)

MethodEndpointDescription
POST/api/commission/referralTrack a referral activity
POST/api/commission/viewTrack a view activity
POST/api/commission/shareTrack a share activity
POST/api/commission/subscriptionTrack a subscription activity
POST/api/commission/batchBatch-track multiple activities
GET/api/commission/earnings/{userId}Earning summary for a user

User / dashboard

MethodEndpointDescription
GET/api/user/dashboardUser dashboard overview
GET/api/user/payoutsList payouts
POST/api/user/payouts/requestRequest a payout
GET/api/user/payouts/{payout}Payout detail
GET/api/user/leaderboardLeaderboard
GET/api/user/leaderboard/{period}Leaderboard for a period

Admin (DevOps only)

MethodEndpointDescription
/api/admin/platformsFull CRUD + restore/forceDelete for Platform records
POST/api/admin/platforms/{platform}/regenerate-api-keyRotate a platform API key
POST/api/admin/platforms/{platform}/regenerate-webhook-secretRotate a platform webhook secret
/api/admin/commission-ratesManage commission-rate presets (+ bulk-update)
/api/admin/activity-typesManage activity types
/api/admin/point-conversion-ratesManage points conversion (+ preview)
/api/admin/transactionsApprove / reject / reverse / bulk-approve
/api/admin/payoutsApprove / complete / reject payouts
GET/api/admin/analytics/*overview, platforms, activities, earnings, cohorts
/api/admin/webhook-logsLogs, platform-stats, retry, bulk-retry, cleanup
POST/api/admin/leaderboard/refreshRefresh leaderboard

Frequently Asked Questions

Do I need to send the register payload of my endpoint to e-auth before my users can log in?
No. Registration is handled inside the SSO flow. When your user signs in on the auth page (or you exchange their credentials in Step 3), the auth service checks whether a platform account already exists for that email. If none exists, it auto-creates one and links it to the user's primary account. If the email has never been seen at all, the auth login page's Register tab (or the /api/auth/register endpoint) creates the primary account first. You only need to call register yourself for backend-only sign-ups.
Users can sign in on every platform — how do accounts relate to each other?
Each email address has exactly one primary account (created the first time the email appears anywhere). Signing into any other platform creates a linked account with the same email, flagged with is_primary_account: false and a primary_user_id pointing to the primary. The whole family shares login credentials and, in Step 4, one canonical profile. Your platform only ever sees its own linked account (platform, platform_user_id, platform_role).
My platform is not in the system. What do I do?
A developer cannot sign users in until the platform is registered — the allowlist fails closed. Someone with admin access to the e-auth admin project (typically the platform DevOps) creates your Platform record via POST /api/admin/platforms (or the internal dashboard) and adds your platform code + callback URI to config/sso.php for each environment. Ask your DevOps contact; this is a two-minute task for them. If you maintain the auth repo yourself, you can do it directly using the payloads in Getting Started.
Why do I get 403 Redirect URI is not allowed?
Your redirect_uri is not on the allowlist for the current environment, or the platform code isn't registered. The match is exact (trailing slash ignored) — https://app.com/callback and https://app.com/callback/ are the same, but https://app.com/callback/extra is rejected, and so is a different host or scheme. Double-check the environment: local, staging and production each have their own allowed URIs.
What are auth_code, session_token, and the JWT — and how long do they live?
Three different artifacts. auth_code — generated by initiate; single-use; expires in 10 minutes; powers Step 3. session_token — issued by sso/login (also the value your callback URL carries); valid 24 hours; verified in Step 4. token/api_token — the JWT for the auth API, minted by sso/login and verify-sso-token. The JWT is accepted only on the auth service (see next question).
The e-auth JWT doesn't work on my own API — is that a bug?
Not a bug, it's by design. Every product signs its own JWTs with its own JWT_SECRET, so an e-auth token is only valid against e-auth endpoints. The eproperties integration solves this by exchanging the verified identity (Step 4) for its own local JWT after signing the user in. Your app should do the same: verify with e-auth, then mint your own session. Do not try to share one JWT across products.
On a returning user's first SSO login the password gets rejected. Why?
Linking a new platform account to an existing primary account requires the user to prove ownership of that primary password — otherwise anyone could claim someone else's identity by typing their email. If your callback sends credentials and they're wrong against the primary, use the auth login page (no credentials) and let the user type their real password there, or treat "Invalid password" as a failed attempt and stop.
What is state and why is it recommended?
state is a CSRF token you generate, keep in your own session, and compare when the browser comes back to your callback. It proves the response belongs to a flow you started. Use a random string per attempt and compare with a timing-safe comparison (hash_equals in PHP).
Can I use e-auth from a mobile app?
Yes — the Central SSO flow runs entirely over HTTP. Apps open redirect_url in a browser or webview (OAuth-style out-of-band flow), the callback lands on your redirect URI, and your backend exchanges/verifies exactly as the web example does. Register the callback URL for each environment in config/sso.php.
How do I know whether a user is new to my platform?
The sso/login response includes is_new_platform_account — true when the linked platform account was just auto-created. Use it to trigger onboarding, profile completion, or a welcome flow. The primary account may of course be older; that's normal and desired.
I'm not a developer and just want my product to "have the login" — what's the short version?
You need two things: (1) your product's platform code registered with the Essential Auth admin/DevOps, and (2) a developer to add the button and the callback described in the Central SSO guide. Once your platform code is registered and your callback URL is allowlisted for your environment, the developer work is a couple of files and takes under an hour.
How do I debug the flow?
Check the response status codes first: 403 — allowlist (platform registered? URI exact? right environment?). 422 — validation (spelling of fields?). 401 — expired/used auth_code or a wrong password. 500 — something is misconfigured server-side (e.g. app.eauth_login_url not set); check me on Slack or ping the DevOps with your platform, your exact redirect_uri, and the failing HTTP response.