A simple RESTful authentication API written in Go with user registration, login (JWT), and secure profile access.
- 📝 Register new users
- 🔑 Login with username and password
- 🛡 JWT-based authentication
- 🗂 JSON-based user storage (no database required)
- ⚙️ Clean and minimal Go codebase
Registers a new user.
Request Body:
{
"username": "valera",
"password": "12345"
}Response:
{"message":"User registered"}Authenticates a user and returns a JWT token.
Request Body:
{
"username": "valera",
"password": "12345"
}Response:
{"token":"<JWT_TOKEN>"}Returns current user info based on JWT.
Header:
Authorization: Bearer <JWT_TOKEN>
Response:
{"username":"valera"}# 1. Set JWT secret
export JWT_SECRET="mysecretkey"
# 2. Run server
go run main.goA student on the path to Yandex. One step at a time.
GitHub: CraftStick