A JWT-authenticated RESTful API written in C#/.NET Core 2.2 for use by client applications in the annual Mammal March Madness tournament. If you have feedback or would like to contribute, please reach out. I'm still learning and would love to hear from you.
- New user registration
- SHA256 password hashing
- JSON Web Tokens (JWT) generation
- JWT expiration and refresh
- GET:
- Animals
- Battle Participants
- Users
- Battle Results
- Animals by Category
- Service to generate a fully seeded bracket
- GET bracket picks for individual users
- Scoring service
- POST, PUT, DELETE functionality
- Create SQL file for inserting test data
Prerequisites:
- C# compatible IDE
- .NET Core 2.2 SDK and runtime
- PostgreSQL
Instructions:
- Fork or clone this repository
- Open solution file and restore packages
- Create database tables using included 'mmm_bracket_postgres_create.sql' file
- Configure user secrets for:
- Database connection string
-
{ Database: { ConnectionString: "" } }
-
- JWT secrets
-
{ JWTSettings: { SecretKey: "random secure string here", Issuer: "MMM_Bracket", Audience: "MMM_Bracket_API" } }
-
- Database connection string
- Build and run solution
- Authentication instructions:
- Send POST request to /api/authentication/register with JSON body to register new user:
{ "username": "username", "password": "password" }
- Include the returned JWT as bearer token for authenticating requests
- Send POST request to /api/authentication/refresh with JSON body (including expired access token and valid refresh token) to refresh an expired token:
{ "accessToken": "", "refreshToken": "" }
- Send POST request to /api/authentication/register with JSON body to register new user: