Auth HTTP Service¶
There is predefined HTTP service for authentication.
1. Install InfinniPlatform.Auth.HttpService
package:
dotnet add package InfinniPlatform.Auth.HttpService -s https://www.myget.org/F/infinniplatform/
2. Call AddAuthHttpService() in ConfigureServices()
:
using System;
using InfinniPlatform.AspNetCore;
using Microsoft.Extensions.DependencyInjection;
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddAuthHttpService();
// ...
return services.BuildProvider();
}
// ...
}
After that next authentication API will be available via HTTP.
-
POST
/Auth/SignIn/
¶ Authenticates the user based on the specified user key and password and starts user session. User’s id, username, email or phone number can be used as user key. This method will try to find user using key one-by-one, so can be less effective than methods for specific user key (see below).
Example:
curl -X POST \ -H "Content-Type: application/json" \ -d '{"UserKey":"user1","Password":"qwerty"}' \ http://localhost:5000/Auth/SignIn
Request Headers: - Content-Type – application/json
Response Headers: - Content-Type – application/json
- Set-Cookie – User Cookies
Status Codes: - 200 OK – OK
- 400 Bad Request – Validation Error
- 500 Internal Server Error – Internal Server Error
-
POST
/Auth/SignInById/
¶ Authenticates the user based on the specified name and password and starts user session.
Example:
curl -X POST \ -H "Content-Type: application/json" \ -d '{"Id":"9d63e3d2-cf06-4c85-a8d3-ca634dfc0131","Password":"qwerty"}' \ http://localhost:5000/Auth/SignInById
Request Headers: - Content-Type – application/json
Response Headers: - Content-Type – application/json
- Set-Cookie – User Cookies
Status Codes: - 200 OK – OK
- 400 Bad Request – Validation Error
- 500 Internal Server Error – Internal Server Error
-
POST
/Auth/SignInByUserName/
¶ Authenticates the user based on the specified id and password and starts user session.
Example:
curl -X POST \ -H "Content-Type: application/json" \ -d '{"UserName":"user1","Password":"qwerty"}' \ http://localhost:5000/Auth/SignInInternal
Request Headers: - Content-Type – application/json
Response Headers: - Content-Type – application/json
- Set-Cookie – User Cookies
Status Codes: - 200 OK – OK
- 400 Bad Request – Validation Error
- 500 Internal Server Error – Internal Server Error
-
POST
/Auth/SignInByEmail/
¶ Authenticates the user based on the specified email and password and starts user session.
Example:
curl -X POST \ -H "Content-Type: application/json" \ -d '{"Email":"user1@infinni.ru","Password":"qwerty"}' \ http://localhost:5000/Auth/SignInByEmail
Request Headers: - Content-Type – application/json
Response Headers: - Content-Type – application/json
- Set-Cookie – User Cookies
Status Codes: - 200 OK – OK
- 400 Bad Request – Validation Error
- 500 Internal Server Error – Internal Server Error
-
POST
/Auth/SignInByPhoneNumber/
¶ Authenticates the user based on the specified phone number and password and starts user session.
Example:
curl -X POST \ -H "Content-Type: application/json" \ -d '{"PhoneNumber":"+73216549877","Password":"qwerty"}' \ http://localhost:5000/Auth/SignInByPhoneNumber
Request Headers: - Content-Type – application/json
Response Headers: - Content-Type – application/json
- Set-Cookie – User Cookies
Status Codes: - 200 OK – OK
- 400 Bad Request – Validation Error
- 500 Internal Server Error – Internal Server Error
-
POST
/Auth/SignOut/
¶ Terminates the user session.
Example:
curl -X POST http://localhost:5000/Auth/SignOut
Response Headers: Status Codes: - 200 OK – OK
- 400 Bad Request – Validation Error
- 500 Internal Server Error – Internal Server Error