Skip to content

Commit e0be55d

Browse files
committed
add auth code
1 parent 1a32aed commit e0be55d

27 files changed

+823
-10
lines changed

session 6/BooksLibrary/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"object-curly-spacing": ["warn", "always"],
3434
"space-infix-ops": "warn",
3535
"key-spacing": [
36-
"warn",
36+
"off",
3737
{
3838
"singleLine": {
3939
"beforeColon": false,

session 6/BooksLibrary/package-lock.json

Lines changed: 209 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

session 6/BooksLibrary/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"build": "tsc",
88
"start": "tsc && ts-node --files ./src/index.ts",
9+
"start:dev": "tsc && ts-node --files ./src/index.ts --watch",
910
"lint:fix": "eslint ./src/** --fix"
1011
},
1112
"author": "akash jadhav",
@@ -16,6 +17,7 @@
1617
"@types/express-fileupload": "^1.2.2",
1718
"@typescript-eslint/eslint-plugin": "^5.13.0",
1819
"@typescript-eslint/parser": "^5.13.0",
20+
"@types/jsonwebtoken": "^8.5.8",
1921
"eslint": "^8.10.0",
2022
"eslint-config-google": "^0.14.0",
2123
"prettier": "2.5.1",
@@ -26,6 +28,7 @@
2628
"dotenv": "^16.0.0",
2729
"express": "^4.17.3",
2830
"express-fileupload": "^1.3.1",
31+
"jsonwebtoken": "^8.5.1",
2932
"reflect-metadata": "^0.1.13",
3033
"tsyringe": "^4.6.0"
3134
}

session 6/BooksLibrary/src/api/controllers/user.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import express from 'express';
2+
import { Loader } from '../../startup/loader';
23
import { UserService } from '../../services/user.service';
34

45
export class UserController {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'reflect-metadata';
2+
import { ConfigurationManager } from '../config/configuration.manager';
3+
import { DependencyContainer } from 'tsyringe';
4+
import { CustomAuthenticator } from './custom/custom.authenticator';
5+
import { CustomAuthorizer } from './custom/custom.authorizer';
6+
7+
////////////////////////////////////////////////////////////////////////////////
8+
9+
export class AuthInjector {
10+
static registerInjections(container: DependencyContainer) {
11+
const authentication = ConfigurationManager.Authentication();
12+
const authorization = ConfigurationManager.Authorization();
13+
14+
if (authentication === 'Custom') {
15+
container.register('IAuthenticator', CustomAuthenticator);
16+
}
17+
if (authorization === 'Custom') {
18+
container.register('IAuthorizer', CustomAuthorizer);
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)