Skip to content

Latest commit

 

History

History
201 lines (153 loc) · 3.13 KB

README.md

File metadata and controls

201 lines (153 loc) · 3.13 KB

globalauth

Easy to use and secure authentication server. Users do not have to give their email, only create a username and password.

Written for use with bun!

Endpoints

Login/Create Endpoints

POST /api/v1/users/create

Create a new user.

{
    "username": string;
    "uuid": string;
    "token": string;
}

POST /api/v1/users/login

Login to an existing account.

{
    "username": string;
    "token": string;
}

Tokens Endpoints

POST /api/v1/users/@me/tokens

Create a new token for the specified account.

{
    "username": string;
    "activeToken": string;
}

PUT /api/v1/users/@me/tokens

Validate an existing token for the specified account.

{
    "username": string;
    "activeToken": string;
    "tokenToValidate": string;
}

DELETE /api/v1/users/@me/tokens

Delete an existing token for the specified account.

{
    "username": string;
    "activeToken": string;
    "tokenToDelete": string;
}

Profile Data Endpoints

PUT /api/v1/users/@me

Get the profile data from the specified account.

{
    "username": string;
    "activeToken": string;
}

PUT /api/v1/users/@me/update

Add profile data to the specified account.

{
    "username": string;
    "activeToken": string;
    "data": {
        [key: string]: string;
    }
}

DELETE /api/v1/users/@me/update

Delete profile data from the specified account.

{
    "username": string;
    "activeToken": string;
    "data": string[];
}

Device Endpoints

PUT /api/v1/users/@me/devices

Return a list of all registered devices for the specified user.

{
    "username": string;
    "activeToken": string;
}

DELETE /api/v1/users/@me/devices

Delete a device by token for the specified user.

{
    "username": string;
    "activeToken": string;
    "tokenToDelete": string;
}

Endpoint Returns

All endpoints will return JSON similar to the type example below.

{
    "s": "succeeded" | "failed",
    "d": {
        [key: string]: any
    }
}

For example, a successful user creation event might look similar to this:

Request: POST /api/v1/users/create

{
    "username": "example",
    "password": "example"
}

Response:

{
    "s": "succeeded",
    "d": {
        "username": "example",
        "uuid": "795a5ed5-2906-4508-ba75-3e003599e97d",
        "token": "2cb89f99439fa3ec16f15304"
    }
}

But a failed user creation event that didn't pass the password field might look similar to this:

Request: POST /api/v1/users/create

{
    "username": "example"
}

Response:

{
    "s": "failed",
    "d": {
        "message": "Missing required body fields."
    }
}

Development

  • Server:
    • Clone the repository
    • Run cd globalauth
    • Make sure you have bun installed
    • Run bun install
    • Start server with bun run dev
  • Client:
    • Clone the repository
    • Run cd globalauth/client
    • Run npm i
    • Watch with npm run watch and npm run watch:vite