auth

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

get.js (879B)


      1 import { app } from '../../../app.js';
      2 import { authenticateAdminRequest } from '../../../lib/admin-auth.js';
      3 import { getAdminRealmUserDetail } from '../../../lib/admin-users.js';
      4 import { HttpError } from '../../../lib/http/http-error.js';
      5 
      6 export default {
      7   method: 'get',
      8   path: '/api/v1/admin/realms/:realm/users/:userId',
      9   name: 'admin.users.get',
     10   async handler(req) {
     11     const auth = await authenticateAdminRequest(req, {
     12       realmSlug: req.params.realm,
     13     });
     14     const detail = await getAdminRealmUserDetail({
     15       systemDb: auth.systemDb,
     16       realmDb: auth.realmDb,
     17       realm: auth.realm,
     18       userId: req.params.userId,
     19       actor: auth.user,
     20       actorRoles: auth.roles,
     21     });
     22     if (!detail) {
     23       throw new HttpError(404, 'user_not_found', 'User not found');
     24     }
     25 
     26     return new app.HttpOk(detail, { 'cache-control': 'no-store' });
     27   },
     28 };