mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 18:37:05 +00:00
OK, I think we are done with the new JWT package
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
# Iris JWT Tutorial
|
||||
|
||||
This example show how to use JWT with domain-driven design pattern with Iris. There is also a simple Go client which describes how you can use Go to authorize a user and use the server's API.
|
||||
|
||||
## Run the server
|
||||
|
||||
```sh
|
||||
$ go run main.go
|
||||
```
|
||||
|
||||
## Authenticate, get the token
|
||||
|
||||
```sh
|
||||
$ curl --location --request POST 'http://localhost:8080/signin' \
|
||||
--header 'Content-Type: application/x-www-form-urlencoded' \
|
||||
@@ -13,6 +19,8 @@ $ curl --location --request POST 'http://localhost:8080/signin' \
|
||||
> $token
|
||||
```
|
||||
|
||||
## Get all TODOs for this User
|
||||
|
||||
```sh
|
||||
$ curl --location --request GET 'http://localhost:8080/todos' \
|
||||
--header 'Authorization: Bearer $token'
|
||||
@@ -20,6 +28,8 @@ $ curl --location --request GET 'http://localhost:8080/todos' \
|
||||
> $todos
|
||||
```
|
||||
|
||||
## Get a specific User's TODO
|
||||
|
||||
```sh
|
||||
$ curl --location --request GET 'http://localhost:8080/todos/$id' \
|
||||
--header 'Authorization: Bearer $token'
|
||||
@@ -27,6 +37,8 @@ $ curl --location --request GET 'http://localhost:8080/todos/$id' \
|
||||
> $todo
|
||||
```
|
||||
|
||||
## Get all TODOs for all Users (admin role)
|
||||
|
||||
```sh
|
||||
$ curl --location --request GET 'http://localhost:8080/admin/todos' \
|
||||
--header 'Authorization: Bearer $token'
|
||||
@@ -34,6 +46,8 @@ $ curl --location --request GET 'http://localhost:8080/admin/todos' \
|
||||
> $todos
|
||||
```
|
||||
|
||||
## Create a new TODO
|
||||
|
||||
```sh
|
||||
$ curl --location --request POST 'http://localhost:8080/todos' \
|
||||
--header 'Authorization: Bearer $token' \
|
||||
@@ -46,5 +60,3 @@ $ curl --location --request POST 'http://localhost:8080/todos' \
|
||||
> Status Created
|
||||
> $todo
|
||||
```
|
||||
|
||||
TODO: write the article on https://medium.com/@kataras, https://dev.to/kataras and linkedin first.
|
||||
|
||||
Reference in New Issue
Block a user