auth

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

list.js (810B)


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