1.0.61 • Published 1 month ago

@koakh/nestjs-package-jwt-authentication-ldap v1.0.61

Weekly downloads
26
License
MIT
Repository
github
Last release
1 month ago

README

Create a test package

# bootstrap a new nest test app
$ nest new test
$ cd test
# install deps
$ npm i
$ npm i @koakh/nestjs-package-jwt-authentication-ldap @nestjs/config
# edit AppModule
$ code src/app.module.ts

add AuthModule and ConfigModule from @koakh/nestjs-package-jwt-authentication-ldap and @nestjs/config

src/app.module.ts

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AuthModule } from '@koakh/nestjs-package-jwt-authentication-ldap';
import { ConfigModule } from '@nestjs/config';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true, }),
    AuthModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})

export class AppModule { }

add a test/.env file

HTTP_SERVER_PORT="3010"
ACCESS_TOKEN_JWT_SECRET="secretKeyAccessToken"
ACCESS_TOKEN_EXPIRES_IN="15m"
REFRESH_TOKEN_JWT_SECRET="secretKeyRefreshToken"
REFRESH_TOKEN_EXPIRES_IN="7d"
REFRESH_TOKEN_SKIP_INCREMENT_VERSION="false"
LDAP_ADDRESS="192.168.1.1:2210"
LDAP_BIND_DN="cn=administrator,cn=users,dc=c3edu,dc=online"
LDAP_BIND_CREDENTIALS="secretCredentials"
LDAP_SEARCH_BASE="dc=c3edu,dc=online"
LDAP_SEARCH_USER_FILTER="(cn={{username}})"
LDAP_SEARCH_USER_ATTRIBUTES="cn,givenName,sn,displayName,userPrincipalName,memberOf,userAccountControl,objectCategory,distinguishedName,mail,lastLogonTimestamp,gender,c3UserRole,dateOfBirth,studentID,telephoneNumber,extraPermission"
LDAP_SEARCH_CACHE_FILTER="(objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=c3edu,DC=online)"
LDAP_BASE_DN="dc=c3edu,dc=online"
LDAP_NEW_USER_DN_POSTFIX="ou=C3student,ou=People"
OPENAPI_TITLE="Consumer App"
OPENAPI_DESCRIPTION="Koakh NestJS Jwt Authentication Package LDAP Consumer App"
OPENAPI_VERSION="1.0.0"
OPENAPI_TAG="nestjs, typescript, ldap, auth, security"

Run App

$ npm run start:dev

Test Endpoints

# clone client.http
wget https://raw.githubusercontent.com/koakh/NestJsPackageJwtAuthentication/main/client.http

Note: required the awesome REST Client

now test all requests

or test with a simple curl

$ curl --request POST \
  --url http://localhost:3010/auth/login \
  --header 'content-type: application/json' \
  --header 'user-agent: vscode-restclient' \
  --data '{"username": "admin","password": "12345678"}' \
  | jq

{
  "user": {
    "id": "efeed3eb-c0a2-4b3e-816f-2a42ca8451b3",
    "username": "admin",
    "givenName": "Pietra",
    "sn": "Heine",
    "email": "pheine0@illinois.edu",
    "roles": [
      "USER",
      "ADMIN"
    ],
    "createdDate": 1597444307,
    "metaData": {
      "key": "value"
    }
  },
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9........"
}

we are done

1.0.61

1 month ago

1.0.60

2 months ago

1.0.59

2 months ago

1.0.58

3 months ago

1.0.57

3 months ago

1.0.56

8 months ago

1.0.55

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.54

2 years ago

1.0.53

2 years ago

1.0.52

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.49

2 years ago

1.0.45

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.26

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago