auth

Main authentication module for my projects
git clone git://git.finwo.net/app/auth
Log | Files | Refs

lookup.js (769B)


      1 import { app } from '../../../app.js';
      2 import { authenticateAdminRequest } from '../../../lib/admin-auth.js';
      3 import { lookupAdminRealmUser } from '../../../lib/admin-users.js';
      4 
      5 export default {
      6   method: 'get',
      7   path: '/api/v1/admin/realms/:realm/user-lookup',
      8   name: 'admin.users.lookup',
      9   async handler(req) {
     10     const auth = await authenticateAdminRequest(req, {
     11       realmSlug: req.params.realm,
     12     });
     13     const url = new URL(req.url, 'http://localhost');
     14     const user = await lookupAdminRealmUser({
     15       systemDb: auth.systemDb,
     16       realmDb: auth.realmDb,
     17       realm: auth.realm,
     18       identifier: url.searchParams.get('identifier'),
     19     });
     20 
     21     return new app.HttpOk(
     22       { ok: true, user },
     23       { 'cache-control': 'no-store' }
     24     );
     25   },
     26 };