Skip to content

Commit

Permalink
Adding a [Roles] attribute for specifying roles in a more meaningful way
Browse files Browse the repository at this point in the history
  • Loading branch information
einari committed Aug 27, 2024
1 parent bfdc403 commit 032a85c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Source/DotNET/Applications/Authorization/RolesAttribute.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// Represents an <see cref="AuthorizeAttribute"/> for specifying roles.
/// </summary>
public sealed class RolesAttribute : AuthorizeAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="RolesAttribute"/> class.
/// </summary>
/// <param name="roles">Roles that is needed.</param>
public RolesAttribute(params string[] roles)
{
Roles = string.Join(',', roles);
}
}

0 comments on commit 032a85c

Please sign in to comment.