From 032a85cd2f608a8482deb2e4ddc7822d345495df Mon Sep 17 00:00:00 2001 From: Einar Ingebrigtsen Date: Tue, 27 Aug 2024 14:00:36 +0200 Subject: [PATCH] Adding a [Roles] attribute for specifying roles in a more meaningful way --- .../Authorization/RolesAttribute.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Source/DotNET/Applications/Authorization/RolesAttribute.cs diff --git a/Source/DotNET/Applications/Authorization/RolesAttribute.cs b/Source/DotNET/Applications/Authorization/RolesAttribute.cs new file mode 100644 index 00000000..8fc89bd2 --- /dev/null +++ b/Source/DotNET/Applications/Authorization/RolesAttribute.cs @@ -0,0 +1,21 @@ +// Copyright (c) Cratis. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.AspNetCore.Authorization; + +namespace Cratis.Applications.Authorization; + +/// +/// Represents an for specifying roles. +/// +public sealed class RolesAttribute : AuthorizeAttribute +{ + /// + /// Initializes a new instance of the class. + /// + /// Roles that is needed. + public RolesAttribute(params string[] roles) + { + Roles = string.Join(',', roles); + } +} \ No newline at end of file