Go-Auth

Go Auth

A secure authentication system built with Go, JWT, and SQLite. This application provides a complete authentication solution with user registration, login, and protected routes.

Go Version License

Features

Getting Started

Prerequisites

Installation

  1. Clone the repository:
    git clone https://github.com/Andy6309/Go-Auth.git
    cd Go-Auth
    
  2. Install dependencies:
    go mod download
    
  3. Set up environment variables:
    cp .env.example .env
    

    Edit the .env file with your configuration.

Configuration

Create a .env file in the project root:

PORT=3010
JWT_SECRET=your_secure_secret_here
JWT_EXPIRATION=24h
DB_PATH=./db-data/auth.db

Running the Application

  1. Create the database directory:
    mkdir -p db-data
    
  2. Start the server:
    go run cmd/server/main.go
    
  3. Access the application at http://localhost:3010

API Documentation

Authentication

Protected Routes

Project Structure

Go-Auth/
├── cmd/
│   └── server/
│       └── main.go          # Application entry point
├── internal/
│   ├── auth/                # Authentication logic
│   ├── config/              # Configuration management
│   ├── handlers/            # HTTP request handlers
│   ├── middleware/          # HTTP middleware
│   └── models/              # Data models and database operations
├── static/                  # Frontend files
│   └── index.html
├── .env.example             # Example environment variables
├── go.mod                   # Go module definition
└── README.md                # This file

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Screenshots

Login Page

Login Page

Acknowledgments