Skip to content

.NET 7 Web API including JWT Bearer authentication and secure password storage.

Notifications You must be signed in to change notification settings

MatheusMGrassano/WebApiUsers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Users Web API

Sections

Description

Features

Tools required

Testing the application

Libraries and technologies

Description

🇬🇧 This repository contains a study project of a Web API using .NET 7 with the goal of implementing CRUD (Create, Read, Update, Delete) functionalities for users, including JWT Bearer authentication and secure password storage.

🇧🇷 Este repositório contém um projeto de estudo da criação de uma API web em .NET 7 com o objetivo de implementar um CRUD completo (Create, Read, Update, Delete) de usuários, incluindo autenticação com JWT Bearer Authentication e armazenamento seguro de senhas.

Features

Method Route JSON Body Action
POST /Login Email + Password Generates the access token
POST /User Name + Email + Password Creates the user
GET /User?offset=5&limit=5 Returns the list of users
GET /User/Id/{id} Returns the user of the id
GET /User/Email/{email} Returns the user of the email
PUT /User/UpdateName Id + Name Updates the user's name
PUT /User/UpdateEmail Id + Email Updates the user's email
PUT /User/UpdatePassword Id + Password Updates the user's password
DELETE /User/Delete/{id} Deletes the user

Request body example

{
  "name": "string",
  "email": "string",
  "password": "string"
}

Response body example

{
  "data": {
    "id": 0,
    "name": "string",
    "email": "string"
  },
  "message": "string",
  "statusCode": 100,
  "error": "string"
}

Tools required

To run the application, you must have these tools installed:

Testing the application

Download or clone the project from: https://github.com/MatheusMGrassano/WebApiUsers.git

Connection String

Change the database connection credentials in the appsettings.json file.

Set the "Data Source" of the connection string using your SQL Server's name and in the "DataBase" choose a name for the database that will be created.

ConnectionString example:

  "ConnectionStrings": {
    "Default": "Data Source=YourServer;Database=YourDatabase;Trusted_connection=true;Encrypt=false;TrustServerCertificate=true"
  }

Generating the migration for the database creation

At your terminal, access the project's root folder and type the following commands:

dotnet tool install --global dotnet-ef
dotnet ef migrations add DataBaseCreation
dotnet ef database update

Running the application

At your terminal, access the project's root folder and type the following command:

dotnet watch run

Then, a new browser tab will open with the Swagger UI, showing all the features of the API.

Libraries and technologies

About

.NET 7 Web API including JWT Bearer authentication and secure password storage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages