Skip to content

CraftStick/auth-api-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Auth API (Go)

A simple RESTful authentication API written in Go with user registration, login (JWT), and secure profile access.


πŸ“¦ Features

  • πŸ“ Register new users
  • πŸ”‘ Login with username and password
  • πŸ›‘ JWT-based authentication
  • πŸ—‚ JSON-based user storage (no database required)
  • βš™οΈ Clean and minimal Go codebase

▢️ Endpoints

πŸ“Œ POST /register

Registers a new user.

Request Body:

{
  "username": "valera",
  "password": "12345"
}

Response:

{"message":"User registered"}

πŸ“Œ POST /login

Authenticates a user and returns a JWT token.

Request Body:

{
  "username": "valera",
  "password": "12345"
}

Response:

{"token":"<JWT_TOKEN>"}

πŸ“Œ GET /me

Returns current user info based on JWT.

Header:

Authorization: Bearer <JWT_TOKEN>

Response:

{"username":"valera"}

πŸ›  How to Run

# 1. Set JWT secret
export JWT_SECRET="mysecretkey"

# 2. Run server
go run main.go

🌟 Author

A student on the path to Yandex. One step at a time.

GitHub: CraftStick

About

πŸ” Simple Auth API using Go and JWT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages