Added more specific readme's + removed obsolete code
This commit is contained in:
@@ -28,3 +28,14 @@ This module contains some useful endpoints for user login / register management.
|
||||
builder.Services.AddHopFrame<DatabaseContext>();
|
||||
```
|
||||
|
||||
# Endpoints
|
||||
By default, the module provides a controller for handling authentication based requests by the user.
|
||||
You can explore the contoller by the build in swagger site from ASP .NET.
|
||||
|
||||
## Disable the Endpoints
|
||||
If you don't want to include these endpoints you need to comment out the AddHopFrame line and only add the Auth middleware:
|
||||
```csharp
|
||||
builder.Services.AddDbContext<DatabaseContext>();
|
||||
//builder.Services.AddHopFrame<DatabaseContext>();
|
||||
services.AddHopFrameAuthentication<TDbContext>();
|
||||
```
|
||||
|
||||
@@ -1,2 +1,74 @@
|
||||
# HopFrame Security module
|
||||
this module contains all handlers for the login and register validation. It also checks the user permissions.
|
||||
|
||||
# Services added in this module
|
||||
You can use these services by specifying them as a dependency. All of them are scoped dependencies.
|
||||
|
||||
## ITokenContext
|
||||
This service provides the information given by the current request
|
||||
|
||||
```csharp
|
||||
public interface ITokenContext {
|
||||
bool IsAuthenticated { get; }
|
||||
|
||||
User User { get; }
|
||||
|
||||
Guid AccessToken { get; }
|
||||
}
|
||||
```
|
||||
|
||||
## IUserService
|
||||
This service simplifies the data access of the user table in the database.
|
||||
|
||||
```csharp
|
||||
public interface IUserService {
|
||||
Task<IList<User>> GetUsers();
|
||||
|
||||
Task<User> GetUser(Guid userId);
|
||||
|
||||
Task<User> GetUserByEmail(string email);
|
||||
|
||||
Task<User> GetUserByUsername(string username);
|
||||
|
||||
Task<User> AddUser(UserRegister user);
|
||||
|
||||
Task UpdateUser(User user);
|
||||
|
||||
Task DeleteUser(User user);
|
||||
|
||||
Task<bool> CheckUserPassword(User user, string password);
|
||||
|
||||
Task ChangePassword(User user, string password);
|
||||
}
|
||||
```
|
||||
|
||||
## IPermissionService
|
||||
This service handles all permission and group interactions with the data source.
|
||||
|
||||
```csharp
|
||||
public interface IPermissionService {
|
||||
Task<bool> HasPermission(string permission, Guid user);
|
||||
|
||||
Task<IList<PermissionGroup>> GetPermissionGroups();
|
||||
|
||||
Task<PermissionGroup> GetPermissionGroup(string name);
|
||||
|
||||
Task EditPermissionGroup(PermissionGroup group);
|
||||
|
||||
Task<IList<PermissionGroup>> GetUserPermissionGroups(User user);
|
||||
|
||||
Task RemoveGroupFromUser(User user, PermissionGroup group);
|
||||
|
||||
Task<PermissionGroup> CreatePermissionGroup(string name, bool isDefault = false, string description = null);
|
||||
|
||||
Task DeletePermissionGroup(PermissionGroup group);
|
||||
|
||||
Task<Permission> GetPermission(string name, IPermissionOwner owner);
|
||||
|
||||
Task AddPermission(IPermissionOwner owner, string permission);
|
||||
|
||||
Task RemovePermission(Permission permission);
|
||||
|
||||
Task<string[]> GetFullPermissions(string user);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace HopFrame.Web;
|
||||
|
||||
[Obsolete("Use HopFrame.Security.AdminPermissions instead")]
|
||||
public static class AdminPermissions {
|
||||
public const string IsAdmin = Security.AdminPermissions.IsAdmin;
|
||||
|
||||
public const string ViewUsers = Security.AdminPermissions.ViewUsers;
|
||||
public const string EditUser = Security.AdminPermissions.EditUser;
|
||||
public const string DeleteUser = Security.AdminPermissions.DeleteUser;
|
||||
public const string AddUser = Security.AdminPermissions.AddUser;
|
||||
|
||||
public const string ViewGroups = Security.AdminPermissions.ViewGroups;
|
||||
public const string EditGroup = Security.AdminPermissions.EditGroup;
|
||||
public const string DeleteGroup = Security.AdminPermissions.DeleteGroup;
|
||||
public const string AddGroup = Security.AdminPermissions.AddGroup;
|
||||
}
|
||||
@@ -41,3 +41,20 @@ This module contains useful helpers for Blazor Apps and an Admin Dashboard.
|
||||
.AddHopFrameAdminPages()
|
||||
.AddInteractiveServerRenderMode();
|
||||
```
|
||||
|
||||
# Services added in this module
|
||||
You can use these services by specifying them as a dependency. All of them are scoped dependencies.
|
||||
|
||||
## IAuthService
|
||||
This service handles all the authentication like login or register. It properly creates all tokens so the user can be identified
|
||||
|
||||
```csharp
|
||||
public interface IAuthService {
|
||||
Task Register(UserRegister register);
|
||||
Task<bool> Login(UserLogin login);
|
||||
Task Logout();
|
||||
|
||||
Task<TokenEntry> RefreshLogin();
|
||||
Task<bool> IsLoggedIn();
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user