chayward1 / users

User accounts and persistent sessions for peons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Users

User accounts and persistent sessions for simple peons.

Overview

  • High performance
  • Low memory footprint
  • HTTP/REST service for…
    • Users
    • Sessions

How to use

Registration

If not already, users can register with the service at the /register endpoint.

POST http://localhost:8081/register
Content-Type: application/json

{
  "name": "chris",
  "pass": "guest"
}
HTTP/1.1 200 OK
Date: Wed, 17 Feb 2021 02:16:32 GMT
Content-Length: 0

Authentication

Once already registered, users can Authenticate using the /authenticate endpoint with the same name and password used during registration.

POST http://localhost:8081/authenticate
Content-Type: application/json

{
  "name": "chris",
  "pass": "guest"
}
{
  "expires": 1613621508848924782,
  "token": "0a0621d8-93e4-4f06-aa06-3ab4a13e8736"
}

Authorization

External services use the /authorize endpoint to identify and authorize the user making the request.

GET http://localhost:8081/authorize
Content-Type: application/json

{
  "secret": "test",
  "token": "0a0621d8-93e4-4f06-aa06-3ab4a13e8736"
}
{
  "userID": 1
}

Logout

When finished with their session, users can use the /logout endpoint to end their session while it remains valid.

GET http://localhost:8081/logout
Content-Type: application/json

{
  "token": "0a0621d8-93e4-4f06-aa06-3ab4a13e8736"
}
HTTP/1.1 200 OK
Date: Wed, 17 Feb 2021 02:19:45 GMT
Content-Length: 0

How does it work?

./docs/example.png

About

User accounts and persistent sessions for peons


Languages

Language:Go 98.1%Language:Dockerfile 1.9%