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