mirror of
https://github.com/hantsy/nestjs-rest-sample.git
synced 2025-12-08 20:36:27 +00:00
docs: update auth.md
This commit is contained in:
parent
d103137f3b
commit
f90635105e
@ -1,6 +1,6 @@
|
|||||||
# Protect your APIs with JWT Token
|
# Protect your APIs with JWT Token
|
||||||
|
|
||||||
In the last post, we connected to a Mongo server and use a real database to replace the dummy data storage. In this post, we will explore how to protect your APIs when exposing to a client application.
|
In the last post, we connected to a Mongo server and used a real database to replace the dummy data storage. In this post, we will explore how to protect your APIs when exposing to a client application.
|
||||||
|
|
||||||
When we come to the security of a web application, technically it will include:
|
When we come to the security of a web application, technically it will include:
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ export class AppController {
|
|||||||
|
|
||||||
It simply calls another method `login` in `AuthService`.
|
It simply calls another method `login` in `AuthService`.
|
||||||
|
|
||||||
```
|
```typescript
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
constructor(
|
constructor(
|
||||||
@ -433,3 +433,4 @@ Try to access the */profile* endpoint using this *access_token*.
|
|||||||
{"username":"hantsy","email":"hantsy@example.com","id":"5f2d0e486a96be1200fefcec","roles":["USER"]}
|
{"username":"hantsy","email":"hantsy@example.com","id":"5f2d0e486a96be1200fefcec","roles":["USER"]}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Grab [the source codes from my github](https://github.com/hantsy/nestjs-sample), switch to branch [feat/auth](https://github.com/hantsy/nestjs-sample/blob/feat/auth).
|
||||||
Loading…
x
Reference in New Issue
Block a user