PHPackages                             gecka/socialite-ncconnect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. gecka/socialite-ncconnect

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

gecka/socialite-ncconnect
=========================

Nc-Connect OAuth2 Provider for Laravel Socialite

2.0.0(2mo ago)01MITPHPPHP ^8.2CI passing

Since Dec 21Pushed 2mo agoCompare

[ Source](https://github.com/Gecka-Apps/NcConnect)[ Packagist](https://packagist.org/packages/gecka/socialite-ncconnect)[ RSS](/packages/gecka-socialite-ncconnect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

NcConnect
=========

[](#ncconnect)

[![CI](https://github.com/Gecka-Apps/NcConnect/actions/workflows/ci.yml/badge.svg)](https://github.com/Gecka-Apps/NcConnect/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/d8cb12d4161bcf3d0abb89bdcd751b5c5812aff012d9323cd8cc56633e950041/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322b2d373737424234)](https://www.php.net)[![Laravel Socialite](https://camo.githubusercontent.com/d48711296dd9994257c7b72ca5fbb638c876108f533aa3971879cfda26116a0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f536f6369616c6974652d50726f76696465722d464632443230)](https://socialiteproviders.com)

NC Connect OAuth2 Provider for Laravel Socialite.

About
-----

[](#about)

NcConnect is a [Laravel Socialite](https://laravel.com/docs/socialite) provider for [NC Connect](https://connect.gouv.nc), the authentication platform of the Government of New Caledonia. It implements the OpenID Connect protocol over the NC Connect V3 (Keycloak) infrastructure.

Features
--------

[](#features)

- OAuth2 / OpenID Connect authentication flow
- Nonce validation on id\_token (replay attack protection)
- User profile with identity claims (name, email, birthdate, gender, etc.)
- Typed accessors on the User object for NC Connect specific claims
- Token refresh support (V3 tokens expire after 30 minutes)
- Logout with post-redirect URI (RP-Initiated Logout)
- Configurable authentication method (`client_secret_basic` or `client_secret_post`)
- Automatic environment switching (production / development)

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10+
- A registered NC Connect client (contact )

Installation
------------

[](#installation)

```
composer require gecka/socialite-ncconnect
```

### Configuration

[](#configuration)

Add to `config/services.php`:

```
'ncconnect' => [
    'client_id' => env('NCCONNECT_CLIENT_ID'),
    'client_secret' => env('NCCONNECT_CLIENT_SECRET'),
    'redirect' => env('NCCONNECT_REDIRECT_URI'),
    'force_dev' => env('NCCONNECT_FORCE_DEV'),
    'logout_redirect' => env('NCCONNECT_LOGOUT_REDIRECT'),
    'auth_method' => env('NCCONNECT_AUTH_METHOD', 'client_secret_basic'),
],
```

### Register the provider

[](#register-the-provider)

**Laravel 11+** — in `app/Providers/AppServiceProvider.php`:

```
use Illuminate\Support\Facades\Event;
use SocialiteProviders\Manager\SocialiteWasCalled;
use SocialiteProviders\NcConnect\NcConnectExtendSocialite;

public function boot(): void
{
    Event::listen(SocialiteWasCalled::class, NcConnectExtendSocialite::class.'@handle');
}
```

**Laravel 10** — in `app/Providers/EventServiceProvider.php`:

```
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        \SocialiteProviders\NcConnect\NcConnectExtendSocialite::class.'@handle',
    ],
];
```

Usage
-----

[](#usage)

### Authentication

[](#authentication)

```
// Redirect to NC Connect
return Socialite::driver('ncconnect')->redirect();

// Handle callback
$user = Socialite::driver('ncconnect')->user();
```

### Refreshing tokens

[](#refreshing-tokens)

Access tokens expire after 30 minutes in V3. Use the built-in `refreshToken()` method:

```
$token = Socialite::driver('ncconnect')->refreshToken($refreshToken);

$token->token;        // new access token
$token->refreshToken; // new refresh token
$token->expiresIn;    // expiry in seconds
```

### Logout

[](#logout)

The `generateLogoutURL()` method builds an [RP-Initiated Logout](https://openid.net/specs/openid-connect-rpinitiated-1_0.html) URL.

```
// Basic logout (uses logout_redirect from config)
$logoutUrl = Socialite::driver('ncconnect')->generateLogoutURL();

// With id_token_hint (recommended — enables seamless logout)
$logoutUrl = Socialite::driver('ncconnect')->generateLogoutURL($idTokenHint);

// With a custom post-logout redirect URI
$logoutUrl = Socialite::driver('ncconnect')->generateLogoutURL($idTokenHint, 'https://example.com/logged-out');

// Without arguments and no logout_redirect config: returns the bare logout endpoint
```

The `id_token_hint` is available on the User object after authentication:

```
$user = Socialite::driver('ncconnect')->user();
$user->tokenId; // store this for logout
```

User object
-----------

[](#user-object)

The returned `User` object extends the Socialite base user with typed accessors for NC Connect claims:

AccessorReturn typeDescription`$user->id``string`Unique identifier (sub)`$user->email``?string`Email address`$user->isEmailVerified()``bool`Whether the email is verified`$user->getVerifiedLevel()``int`Verification level (0 = unverified, 1 = declarative, 2 = digital)`$user->getPreferredUsername()``string`Display name`$user->getGivenName()``string`All given names`$user->getFirstName()``string`First given name only`$user->getFamilyName()``string`Family name`$user->getBirthdate()``string`Date of birth (YYYY-MM-DD)`$user->getGender()``string`Gender (male/female)`$user->getBirthplace()``string`Place of birth`$user->tokenId``?string`ID token hint (for logout)`$user->token``string`Access token`$user->refreshToken``?string`Refresh token`$user->expiresIn``int`Token expiry in secondsAll attributes are also accessible via `$user->getRaw()` for the full userinfo response.

Scopes
------

[](#scopes)

Default: `openid`, `identite_pivot`, `profile`, `email`

Available: `openid`, `profile`, `email`, `birth`, `identite_pivot`

Authentication methods
----------------------

[](#authentication-methods)

MethodConfig valueDescriptionClient Secret Basic`client_secret_basic` (default)Credentials sent as Basic auth headerClient Secret Post`client_secret_post`Credentials sent in POST bodyConfiguration reference
-----------------------

[](#configuration-reference)

Env variableDescriptionDefault`NCCONNECT_CLIENT_ID`OAuth2 client ID—`NCCONNECT_CLIENT_SECRET`OAuth2 client secret—`NCCONNECT_REDIRECT_URI`Callback URL after login—`NCCONNECT_LOGOUT_REDIRECT`Redirect URL after logout—`NCCONNECT_FORCE_DEV`Force dev endpoints in production—`NCCONNECT_AUTH_METHOD`Authentication method`client_secret_basic`Upgrading
---------

[](#upgrading)

Migrating from NC Connect V2 to V3 (Keycloak)? See [UPGRADE.md](UPGRADE.md).

License
-------

[](#license)

This project is released under the [MIT License](LICENSE).

Authors
-------

[](#authors)

- **Adil Kachbat**
- **Laurent Dinclaux**  — [Gecka](https://gecka.nc)

---

Built with 🥥 and ☕ by [Gecka](https://gecka.nc) — Kanaky-New Caledonia 🇳🇨

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance86

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~798 days

Total

2

Last Release

74d ago

Major Versions

1.0.0 → 2.0.02026-02-26

PHP version history (2 changes)1.0.0PHP ^8.0

2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/78fa66cd99208a89203b89229b5a9ec39cdf89ada057637c14a4b571a4407c9c?d=identicon)[gecka](/maintainers/gecka)

---

Top Contributors

[![lucasmichot](https://avatars.githubusercontent.com/u/513603?v=4)](https://github.com/lucasmichot "lucasmichot (16 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (7 commits)")[![loxK](https://avatars.githubusercontent.com/u/136687?v=4)](https://github.com/loxK "loxK (4 commits)")[![akachbat](https://avatars.githubusercontent.com/u/13352152?v=4)](https://github.com/akachbat "akachbat (1 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")[![Max13](https://avatars.githubusercontent.com/u/531249?v=4)](https://github.com/Max13 "Max13 (1 commits)")

---

Tags

laravelprovideroauthsocialitencconnect

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/gecka-socialite-ncconnect/health.svg)

```
[![Health](https://phpackages.com/badges/gecka-socialite-ncconnect/health.svg)](https://phpackages.com/packages/gecka-socialite-ncconnect)
```

###  Alternatives

[socialiteproviders/microsoft

Microsoft OAuth2 Provider for Laravel Socialite

326.1M13](/packages/socialiteproviders-microsoft)[socialiteproviders/instagram

Instagram OAuth2 Provider for Laravel Socialite

421.9M5](/packages/socialiteproviders-instagram)[kovah/laravel-socialite-oidc

OpenID Connect OAuth2 Provider for Laravel Socialite

2073.7k](/packages/kovah-laravel-socialite-oidc)[socialiteproviders/kakao

Kakao OAuth2 Provider for Laravel Socialite

10484.7k4](/packages/socialiteproviders-kakao)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
