New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@ghentcdh/authentication-api

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ghentcdh/authentication-api

GhentCdh Keycloak libraries for authentication

latest
Source
npmnpm
Version
0.6.9
Version published
Weekly downloads
3
-75%
Maintainers
3
Weekly downloads
 
Created
Source

GhentCdh Keycloak libraries for authentication

Backend nestjs

Install the libraries

pnpm add @ghentcdh/auth/vue @ghentcdh/auth/backend

Add following environment variables to the .env file.

      - KEYCLOAK_HOST=$KEYCLOAK_HOST
      - KEYCLOAK_REALM=$KEYCLOAK_REALM

Secure requests

Add the module to your module.ts imports


import {AuthenticationApiModule} from "@ghentcdh/authentication-api";

@Module({
    imports: [AuthenticationApiModule],
})
export class MyModule {
}

Extend the GhentCdhGuard decorator to secure your routes

import { Injectable } from '@nestjs/common';
import { GhentCdhGuard } from '@ghentcdh/authentication-api';
import { HttpService } from '@nestjs/axios';
import { ConfigService } from '@nestjs/config';

@Injectable()
export class MyGuard extends GhentCdhGuard {
  constructor(_httpService: HttpService, _configService: ConfigService) {
    super(_httpService, _configService);
  }
}

Use the guard in your controller

import {MyGuard} from "./my.guard";

@Controller()
export class MyController {
    @UseGuards(MyGuard)
    @Post('/secure')
    async securePath(@User() user: any, @Request() req: any) {
        return user;
    }
}

The @User() decorator will give you the user object from the keycloak token.

TODO list

  • Add roles decorator and implement logic @GhentCdhRoles(['admin'])

Development environment

Make sure the following is added to your hosts file, if you are running a local keycloak instance. Internally the docker containers cannot connect to the localhost:8080 port, so a hook is needed in terms of host rewrite.

echo "127.0.0.1 authentication\n" | sudo tee -a /etc/hosts

Setup docker

TODO describe me

FAQs

Package last updated on 17 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts