3using Microsoft.AspNetCore.Authorization;
4using Microsoft.AspNetCore.Mvc;
5using Microsoft.AspNetCore.Mvc.Filters;
6using Microsoft.Extensions.DependencyInjection;
7using Microsoft.Extensions.Logging;
17#pragma warning disable CA1019
18 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple =
true, Inherited =
true)]
40 RightsType = Api.Rights.RightsType.Administration;
50 RightsType = Api.Rights.RightsType.InstanceManager;
90 RightsType = Api.Rights.RightsType.DreamDaemon;
110 RightsType = Api.Rights.RightsType.Configuration;
120 RightsType = Api.Rights.RightsType.InstancePermissionSet;
126 var services = context.HttpContext.RequestServices;
128 var logger = services.GetRequiredService<ILogger<TgsAuthorizeAttribute>>();
130 if (!authenticationContext.Valid)
132 logger.LogTrace(
"authenticationContext is invalid!");
133 context.Result =
new UnauthorizedResult();
137 if (authenticationContext.User.Require(x => x.Enabled))
140 logger.LogTrace(
"authenticationContext is for a disabled user!");
141 context.Result =
new ForbidResult();
Helper for using the AuthorizeAttribute with the Api.Rights system.
TgsAuthorizeAttribute(InstanceManagerRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
TgsAuthorizeAttribute(ChatBotRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
TgsAuthorizeAttribute(DreamDaemonRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
TgsAuthorizeAttribute(RepositoryRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
TgsAuthorizeAttribute(EngineRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
TgsAuthorizeAttribute(ConfigurationRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
TgsAuthorizeAttribute()
Initializes a new instance of the TgsAuthorizeAttribute class.
void OnAuthorization(AuthorizationFilterContext context)
TgsAuthorizeAttribute(AdministrationRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
TgsAuthorizeAttribute(InstancePermissionSetRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
TgsAuthorizeAttribute(DreamMakerRights requiredRights)
Initializes a new instance of the TgsAuthorizeAttribute class.
Represents the currently authenticated Models.User.
ChatBotRights
Rights for chat bots.
ConfigurationRights
Rights for Models.IConfigurationFiles.
DreamMakerRights
Rights for deployment.
RightsType
The type of rights a model uses.
EngineRights
Rights for engine version management.
RepositoryRights
Rights for the git repository.
InstancePermissionSetRights
Rights for an Models.Instance.
DreamDaemonRights
Rights for managing DreamDaemon.
InstanceManagerRights
Rights for managing Models.Instances.
AdministrationRights
Administration rights for the server.