goauth

command module
v0.0.0-...-674e5f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README

GoAuth - An authentication app which handles register & login via RESTful API

I made this project while learning golang.This backend app is my first project, that I made using GoFiber(A backend framework for Go).

Requirement

  • Go
  • PostgreSQL

Starting the backend server

Setting up files:

    git clone https://github.com/ryszhio/goauth.git
    cd goauth
    mv example.env .env  # Edit your env file to setup database. (Make sure to have postgres and access to database.)

Running Server

    go run main.go

OR

    go build .
    ./goauth

End Points

1. Register
    POST /api/auth/register
2. Login
    POST /api/auth/login
3. Default
    GET /
    POST /

Just returns simple message with goauth working..

How to send request ?

1. Register
    POST /api/auth/register
    
    Body:

    {
        "username": "",
        "display_name": "",
        "password": "",
        "email": "",
        "phone_number": ""
    }

Fill the fields properly & Send Request.

Status Response:

1. 400 - Bad Request

  • Invalid JSON request
  • Invalid email
  • Invalid username
  • Email already taken
  • Username already taken

2. 500 - Internal Server Error

  • Failed to check if email already exists
  • Failed to check if username already exists
  • If failed to hash the password.
  • Failed to write user into the database

3. 201 - Status Created

  • If user is successfully registered.
2. Login
    POST /api/auth/register

    Body:

    {
        "identity": "", 
        "password": ""
    }

Identity field should either contain email or username Fill the field properly.

Status Response:

1. 400 - Bad Request

  • Invalid JSON request

2. 500 - Internal Server Error

  • Failed to retreive info from database
  • Failed to generate JWT Token (JWT are not implemented yet. It just generates token for now)

3. 401 - Status Unauthorized

  • Entered identity or password doesn't match

4. 200 - OK

  • Returns a JWT Token for session based authentication. (JWT are not implemented yet. It just generates token for now)

Packages Used

  • GoFiber (The core backend framework)
  • GORM (For Object-Relation-Mapping & also postgres driver)
  • godotenv (To load environment variables from .env file)

Future Plans

  • Implement Middlewares for protecting routes.
  • Implement JWT for session based authentication.

License

This project is licensed under the Apache License 2.0.

© 2025 Rishab Karki

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package handler is used to handle the request on the register routes
Package handler is used to handle the request on the register routes
internal
auth
Package auth is used to sign and unsign jwt
Package auth is used to sign and unsign jwt
generator
Package generator is used for snowflake purpose
Package generator is used for snowflake purpose
keys
Package keys is used to configure private and public keys for jwt
Package keys is used to configure private and public keys for jwt
Package model got schema defined for GORM and also json
Package model got schema defined for GORM and also json
Package router is used to configure routes
Package router is used to configure routes
Package run holds function to run the app itself
Package run holds function to run the app itself

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL