Libermall ID для разработчиков

Подключите единый вход к своему сервису за 5 минут. Стандартный OpenID Connect — никакого vendor lock-in.

Endpoints

Все endpoints находятся под https://id.libermall.com:

OpenID discovery:    /.well-known/openid-configuration
Authorize:           /login/oauth/authorize
Token:               /api/login/oauth/access_token
UserInfo:            /api/userinfo
JWKS:                /.well-known/jwks
Logout:              /api/logout

OAuth 2.0 / OIDC flow

Стандартный Authorization Code flow с PKCE:

1. Пользователь нажимает «Войти через Libermall ID» на вашем сайте
2. Редирект на /login/oauth/authorize?response_type=code&client_id=...&redirect_uri=...&state=...&scope=openid+profile+email
3. Casdoor показывает форму, юзер логинится (Telegram, TON, email)
4. Casdoor редиректит обратно на ваш redirect_uri с ?code=&state=
5. Ваш сервер обменивает code на access_token через POST /api/login/oauth/access_token
6. Получаете userinfo через GET /api/userinfo с Bearer токеном

SDK для Laravel

Полный пример: github.com/DeFiTON/libermall-id/tree/main/integration-examples/laravel

composer require laravel/socialite socialiteproviders/generic-oauth2

// config/services.php
'libermall' => [
    'host' => env('LIBERMALL_ID_HOST', 'https://id.libermall.com'),
    'client_id' => env('LIBERMALL_ID_CLIENT_ID'),
    'client_secret' => env('LIBERMALL_ID_CLIENT_SECRET'),
    'redirect' => env('APP_URL') . '/oauth/libermall/callback',
],

// routes/web.php
Route::get('/oauth/libermall', fn() => Socialite::driver('libermall')->redirect());
Route::get('/oauth/libermall/callback', [LibermallController::class, 'callback']);

SDK для Next.js

NextAuth.js с Custom Provider:

// pages/api/auth/[...nextauth].js
import NextAuth from 'next-auth';

export default NextAuth({
  providers: [
    {
      id: 'libermall',
      name: 'Libermall ID',
      type: 'oauth',
      wellKnown: 'https://id.libermall.com/.well-known/openid-configuration',
      authorization: { params: { scope: 'openid profile email' } },
      idToken: true,
      checks: ['pkce', 'state'],
      profile(p) { return { id: p.sub, name: p.name, email: p.email }; },
      clientId: process.env.LIBERMALL_CLIENT_ID,
      clientSecret: process.env.LIBERMALL_CLIENT_SECRET,
    },
  ],
});

SDK для Node / Express

npm install openid-client passport passport-openidconnect

// index.js
const { Issuer, Strategy } = require('openid-client');
const passport = require('passport');

(async () => {
  const issuer = await Issuer.discover('https://id.libermall.com/.well-known/openid-configuration');
  const client = new issuer.Client({
    client_id: process.env.LIBERMALL_CLIENT_ID,
    client_secret: process.env.LIBERMALL_CLIENT_SECRET,
    redirect_uris: ['https://yourapp.com/auth/callback'],
    response_types: ['code'],
  });
  passport.use('libermall', new Strategy({ client }, (tokenset, done) => done(null, tokenset.claims())));
})();

Claims в id_token

{
  "iss": "https://id.libermall.com",
  "aud": "your_client_id",
  "sub": "uuid-of-user",
  "preferred_username": "sviatoslav",
  "name": "Sviatoslav Gusev",
  "email": "user@example.com",
  "email_verified": true,
  "picture": "https://t.me/i/userpic/320/...",
  "tg_id": 12345678,
  "tg_username": "defiton",
  "wallets": [{ "chain": "ton", "address": "EQ..." }]
}

Scopes

Регистрация приложения

Пока ручной процесс. Напишите на hello@libermall.com с информацией:

В ответ получите client_id + client_secret.

Поддержка

Issues и feature requests: GitHub Issues.