AdminUtils
Namespace: Commissiestrijd.Utils
Assembly: backend.dll
Utility class for admin-related operations. This class provides methods to set up the admin utilities and check if a user is an admin. It retrieves the user information from the OpenID Connect provider and checks if the user has admin privileges.
public class AdminUtils
Inheritance
Show Inherited Members (7)
Methods
IsAdmin(HttpContext)
Checks if the current user is an admin by retrieving their user information from the OpenID Connect provider. This method uses the access token from the HTTP context to make a request to the user info endpoint and checks if the user has admin privileges.
public static Task<bool> IsAdmin(HttpContext httpContext)
Parameters
Name | Type | Description |
---|---|---|
httpContext | HttpContext | The HTTP context containing the user's authentication information. |
Returns
Type |
---|
Task |
Setup(Uri, string)
Sets up the admin utilities by retrieving the user info endpoint from the OpenID Connect provider using the provided provider URI. This method should be called during application startup to ensure the user info URL is set correctly.
public static void Setup(Uri provider, string adminClaim = "is_admin")