1 unstable release

Uses old Rust 2015

0.1.3 Sep 26, 2018

#142 in #authorization

MIT license

39KB
1K SLoC

HowToCards

REST API

Authentication

You should create token.
Send token in Authorization header.

Example:

Authorization: bearer 0dsi9fjs9dfj89s8djf

Where 0dsi9fjs9dfj89s8djf is your token.

If route requires authentication, and request not provides it:

400 Bad Request is returns.

{
  "ok": false,
  "error": "{ERROR_KIND}"
}

Where ERROR_KIND is:

  • invalid_token
  • unknown_token
  • missing_header

POST /account

Register new account.

Receives:

{
  "email": "string",
  "password": "string"
}

If account registered successfully returns 200 OK.
Otherwise returns 400 Bad Request.

POST /account/session

Login with credentials.

Receieve:

{
  "email": "string",
  "password": "string"
}

Response:

{
  "token": "string"
}

Errors:

400 Bad Request

{
  "ok": false,
  "error": "{ERROR_KIND}"
}

{ERROR_KIND} can be:

  • email_not_found
  • invalid_password

GET /account/session

Get info about current session.

authentication required

Response:

{
  "email": "string"
}

Dependencies

~25–36MB
~565K SLoC