1
0
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:
Gerasimos (Makis) Maropoulos
2020-11-05 10:47:56 +02:00
parent a9e808345b
commit d562f09531
3 changed files with 53 additions and 20 deletions

View File

@@ -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.