1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00
Files
kararas_iris/_examples/auth/jwt/tutorial
dependabot[bot] ad89abcf37 Bump golang.org/x/net in /_examples/auth/jwt/tutorial (#2068)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.4.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.4.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-19 21:11:55 +02:00
..
2020-11-04 21:12:13 +02:00
2020-11-04 21:12:13 +02:00

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

$ go run main.go

Authenticate, get the token

$ curl --location --request POST 'http://localhost:8080/signin' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=admin'

> $token

Get all TODOs for this User

$ curl --location --request GET 'http://localhost:8080/todos' \
--header 'Authorization: Bearer $token'

> $todos

Get a specific User's TODO

$ curl --location --request GET 'http://localhost:8080/todos/$id' \
--header 'Authorization: Bearer $token'

> $todo

Get all TODOs for all Users (admin role)

$ curl --location --request GET 'http://localhost:8080/admin/todos' \
--header 'Authorization: Bearer $token'

> $todos

Create a new TODO

$ curl --location --request POST 'http://localhost:8080/todos' \
--header 'Authorization: Bearer $token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title": "test titlte",
    "body": "test body"
}'

> Status Created
> $todo