An open API service indexing awesome lists of open source software.

https://github.com/librity/ignite_jwt_ttl

Rocket Seat - Ignite - Elixir - Challenge 14 - An authenticated API made with Phoenix and Guardian.
https://github.com/librity/ignite_jwt_ttl

challenge elixir guardian phoenix rocketseat-ignite

Last synced: 15 days ago
JSON representation

Rocket Seat - Ignite - Elixir - Challenge 14 - An authenticated API made with Phoenix and Guardian.

Awesome Lists containing this project

README

          

# Rocket Seat Ignite - JWT Authentication

## Table of Contents

- [About](#about)
- [Endpoints](#endpoints)
- [Setup](#setup)
- [Bash Commands](#bash_commands)
- [Elixir Commands](#elixir_commands)
- [Libs](#libs)
- [Docs](#docs)
- [Resources](#resources)

## About

An authenticated API made with Phoenix and Guardian.

## Endpoints

Built-in:

- `GET` http://localhost:4000/dashboard

`Users`

- `POST` http://localhost:4000/api/users
- `POST` http://localhost:4000/api/users/sign_in

`Repos`

- `GET` http://localhost:4000/api/repos/:username

## Setup

Install `Erlang`, `Elixir` and `Phoenix`.

## Bash Commands

```bash
# Create phoenix app without webpacker or html views
$ mix phx.new app_name --no-webpack --no-html

# Intall dependencies
$ mix deps.get

# Compile project
$ mix compile

# Generate linter config file
$ mix credo.gen.config

# Run linter
$ mix credo --strict

# Start Phoenix dev server on http://localhost:4000
$ mix phx.server

# Start your project as an Interactive Elixir session
$ iex -S mix

# List all configured routes
$ mix phx.routes
```

Tests

```bash
# Run tests
$ mix test

# Run tests w/ coverage report
$ mix test --cover
```

## Elixir Commands

Github client:

```elixir
> Github.Client.get_user_repos("teamon")
> Github.Client.get_user_repos("danilo-vieira")
> Github.Client.get_user_repos("librity")
```

## Libs

- https://github.com/phoenixframework/phoenix
- https://github.com/teamon/tesla
- https://github.com/PSPDFKit-labs/bypass
- https://github.com/dashbitco/mox
- https://github.com/thoughtbot/ex_machina
- https://github.com/riverrun/pbkdf2_elixir
- https://github.com/ueberauth/guardian

## Docs

- https://elixir-lang.org/crash-course.html
- https://hexdocs.pm/guardian/Guardian.html#encode_and_sign/4
- https://hexdocs.pm/guardian/Guardian.Token.Jwt.html#refresh/3

## Resources

- https://www.tutorialspoint.com/elixir/elixir_lists_and_tuples.htm
- https://stackoverflow.com/questions/29566248/how-to-use-io-inspect-on-a-long-list-without-trimming-it
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent