Skip to content

Commit b0dbcec

Browse files
permissions revamp (#45)
- moved from pre-defined roles to granular permissions - custom roles can be defined and given specific permissions - Roles can optionally be pulled from Identity Provider token - new settings for identity provider under ClaimsTransformation
1 parent 2d71d9d commit b0dbcec

File tree

213 files changed

+11274
-5475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+11274
-5475
lines changed

.github/workflows/client.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup dotnet
1616
uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: "6.x.x"
18+
dotnet-version: "8.x.x"
1919

2020
- name: Setup Package Name
2121
id: package_name
@@ -41,7 +41,7 @@ jobs:
4141
run: |
4242
cd ${{ steps.package_name.outputs.name }}
4343
npm install
44-
./node_modules/.bin/nswag run /runtime:Net60
44+
./node_modules/.bin/nswag run /runtime:Net80
4545
4646
- name: Create NuGet Package
4747
run: |
@@ -59,7 +59,6 @@ jobs:
5959
sed -i '/<\/version>/a \ <license type="expression">MIT<\/license>' ${{ steps.package_name.outputs.name }}.nuspec
6060
sed -i '/<\/version>/a \ <licenseUrl>https:\/\/licenses.nuget.org\/MIT<\/licenseUrl>' ${{ steps.package_name.outputs.name }}.nuspec
6161
sed -i '/<\/version>/a \ <projectUrl>https:\/\/github.com\/cmu-sei\/crucible<\/projectUrl>' ${{ steps.package_name.outputs.name }}.nuspec
62-
sed -i '/<\/version>/a \ <repository type="git" url="https:\/\/github.com\/cmu-sei\/crucible.git" \/>' ${{ steps.package_name.outputs.name }}.nuspec
6362
zip -r ../${{ steps.package_name.outputs.name }}.${{ github.event.inputs.clientVersion }}.nupkg *
6463
6564
- name: Publish to Nuget.org as Unlisted

Player.Api.Client/Player.Api.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="System.Text.Json" Version="6.0.1" />
13+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
1414
<PackageReference Include="System.ComponentModel.Annotations" Version="6.0.0-preview.4.21253.7" />
1515
</ItemGroup>
1616

Player.Api.Client/nswag.json

Lines changed: 88 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,101 @@
11
{
2-
"runtime": "Net60",
3-
"swaggerGenerator":{
4-
"fromSwagger":{
5-
"json":"swagger.json"
2+
"runtime": "Net80",
3+
"defaultVariables": null,
4+
"documentGenerator": {
5+
"fromDocument": {
6+
"json": "swagger.json",
7+
"url": "http://redocly.github.io/redoc/openapi.yaml",
8+
"output": null,
9+
"newLineBehavior": "Auto"
610
}
711
},
812
"codeGenerators": {
913
"openApiToCSharpClient": {
10-
"className": "PlayerApiClient",
11-
"namespace": "Player.Api.Client",
12-
"output": "Player.Api.Client.cs",
14+
"clientBaseClass": null,
15+
"configurationClass": null,
16+
"generateClientClasses": true,
17+
"suppressClientClassesOutput": false,
1318
"generateClientInterfaces": true,
19+
"suppressClientInterfacesOutput": false,
20+
"clientBaseInterface": null,
21+
"injectHttpClient": true,
22+
"disposeHttpClient": true,
23+
"protectedMethods": [],
24+
"generateExceptionClasses": true,
25+
"exceptionClass": "ApiException",
26+
"wrapDtoExceptions": true,
27+
"useHttpClientCreationMethod": false,
28+
"httpClientType": "System.Net.Http.HttpClient",
29+
"useHttpRequestMessageCreationMethod": false,
30+
"useBaseUrl": false,
31+
"generateBaseUrlProperty": true,
32+
"generateSyncMethods": false,
33+
"generatePrepareRequestAndProcessResponseAsAsyncMethods": false,
34+
"exposeJsonSerializerSettings": false,
35+
"clientClassAccessModifier": "public",
36+
"typeAccessModifier": "public",
37+
"propertySetterAccessModifier": "",
38+
"generateNativeRecords": false,
1439
"generateContractsOutput": true,
1540
"contractsNamespace": "Player.Api.Client",
1641
"contractsOutputFilePath": "Player.Api.Contracts.cs",
17-
"jsonLibrary": "SystemTextJson",
42+
"parameterDateTimeFormat": "s",
43+
"parameterDateFormat": "yyyy-MM-dd",
44+
"generateUpdateJsonSerializerSettingsMethod": true,
45+
"useRequestAndResponseSerializationSettings": false,
46+
"serializeTypeInformation": false,
47+
"queryNullValue": "",
48+
"className": "PlayerApiClient",
1849
"operationGenerationMode": "SingleClientFromOperationId",
19-
"useBaseUrl": false
50+
"additionalNamespaceUsages": [],
51+
"additionalContractNamespaceUsages": [],
52+
"generateOptionalParameters": false,
53+
"generateJsonMethods": false,
54+
"enforceFlagEnums": false,
55+
"parameterArrayType": "System.Collections.Generic.IEnumerable",
56+
"parameterDictionaryType": "System.Collections.Generic.IDictionary",
57+
"responseArrayType": "System.Collections.Generic.ICollection",
58+
"responseDictionaryType": "System.Collections.Generic.IDictionary",
59+
"wrapResponses": false,
60+
"wrapResponseMethods": [],
61+
"generateResponseClasses": true,
62+
"responseClass": "SwaggerResponse",
63+
"namespace": "Player.Api.Client",
64+
"requiredPropertiesMustBeDefined": true,
65+
"dateType": "System.DateTimeOffset",
66+
"jsonConverters": null,
67+
"anyType": "object",
68+
"dateTimeType": "System.DateTimeOffset",
69+
"timeType": "System.TimeSpan",
70+
"timeSpanType": "System.TimeSpan",
71+
"arrayType": "System.Collections.Generic.ICollection",
72+
"arrayInstanceType": "System.Collections.ObjectModel.Collection",
73+
"dictionaryType": "System.Collections.Generic.IDictionary",
74+
"dictionaryInstanceType": "System.Collections.Generic.Dictionary",
75+
"arrayBaseType": "System.Collections.ObjectModel.Collection",
76+
"dictionaryBaseType": "System.Collections.Generic.Dictionary",
77+
"classStyle": "Poco",
78+
"jsonLibrary": "SystemTextJson",
79+
"generateDefaultValues": true,
80+
"generateDataAnnotations": true,
81+
"excludedTypeNames": [],
82+
"excludedParameterNames": [],
83+
"handleReferences": false,
84+
"generateImmutableArrayProperties": false,
85+
"generateImmutableDictionaryProperties": false,
86+
"jsonSerializerSettingsTransformationMethod": null,
87+
"inlineNamedArrays": false,
88+
"inlineNamedDictionaries": false,
89+
"inlineNamedTuples": true,
90+
"inlineNamedAny": false,
91+
"generateDtoTypes": true,
92+
"generateOptionalPropertiesAsNullable": false,
93+
"generateNullableReferenceTypes": false,
94+
"templateDirectory": null,
95+
"serviceHost": null,
96+
"serviceSchemes": null,
97+
"output": "Player.Api.Client.cs",
98+
"newLineBehavior": "Auto"
2099
}
21100
}
22101
}

Player.Api.Client/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Player.Api.Client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"dependencies": {
3-
"nswag": "^13.15.5"
3+
"nswag": "^14.2.0"
44
}
55
}

Player.Api.Data/Data/Extensions/UserExtensions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@
77

88
namespace Player.Api.Data.Data.Extensions
99
{
10-
public static class DirectoryExtensions
10+
public static class UserExtensions
1111
{
1212
public static IQueryable<UserEntity> IncludePermissions(this IQueryable<UserEntity> query)
1313
{
1414
return query
1515
.Include(u => u.Role)
1616
.ThenInclude(r => r.Permissions)
17-
.ThenInclude(p => p.Permission)
18-
.Include(u => u.Permissions)
19-
.ThenInclude(p => p.Permission);
17+
.ThenInclude(p => p.Permission);
2018
}
2119
}
2220
}

Player.Api.Data/Data/Models/Application.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Player.Api.Data.Data.Models
1010
{
11-
public class ApplicationTemplateEntity
11+
public class ApplicationTemplateEntity : IEntity
1212
{
1313
[Key]
1414
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@@ -29,7 +29,7 @@ public ApplicationTemplateEntity()
2929
}
3030
}
3131

32-
public class ApplicationEntity
32+
public class ApplicationEntity : IEntity
3333
{
3434
[Key]
3535
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@@ -83,7 +83,7 @@ public string GetName()
8383
}
8484
}
8585

86-
public class ApplicationInstanceEntity
86+
public class ApplicationInstanceEntity : IEntity
8787
{
8888
[Key]
8989
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]

Player.Api.Data/Data/Models/File.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Player.Api.Data.Data.Models
1010
{
11-
public class FileEntity
11+
public class FileEntity : IEntity
1212
{
1313
[Key]
1414
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2025 Carnegie Mellon University. All Rights Reserved.
2+
// Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.
3+
4+
namespace Player.Api.Data.Data.Models;
5+
6+
public interface IEntity { }

Player.Api.Data/Data/Models/Notification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Player.Api.Data.Data.Models
1313
{
14-
public class NotificationEntity
14+
public class NotificationEntity : IEntity
1515
{
1616
[Key]
1717
public int Key { get; set; }

Player.Api.Data/Data/Models/Permission.cs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,43 @@
33

44
using Microsoft.EntityFrameworkCore;
55
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6-
using System.Text.Json.Serialization;
76
using System;
8-
using System.Collections.Generic;
97
using System.ComponentModel.DataAnnotations;
108
using System.ComponentModel.DataAnnotations.Schema;
119

1210
namespace Player.Api.Data.Data.Models
1311
{
14-
public class PermissionEntity
12+
public class PermissionEntity : IEntity
1513
{
1614
[Key]
1715
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
1816
public Guid Id { get; set; }
19-
20-
public string Key { get; set; }
21-
22-
public string Value { get; set; }
23-
17+
public string Name { get; set; }
2418
public string Description { get; set; }
25-
26-
public bool ReadOnly { get; set; }
27-
28-
//public string[] Tags { get; set; }
19+
public bool Immutable { get; set; }
2920
}
3021

3122
public class PermissionConfiguration : IEntityTypeConfiguration<PermissionEntity>
3223
{
3324
public void Configure(EntityTypeBuilder<PermissionEntity> builder)
3425
{
35-
builder.HasIndex(x => new { x.Key, x.Value }).IsUnique();
26+
builder.HasIndex(x => x.Name).IsUnique();
3627
}
3728
}
29+
30+
public enum SystemPermission
31+
{
32+
CreateViews,
33+
ViewViews,
34+
EditViews,
35+
ManageViews,
36+
ViewUsers,
37+
ManageUsers,
38+
ViewApplications,
39+
ManageApplications,
40+
ViewRoles,
41+
ManageRoles,
42+
ViewWebhookSubscriptions,
43+
ManageWebhookSubscriptions
44+
}
3845
}

Player.Api.Data/Data/Models/Role.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010

1111
namespace Player.Api.Data.Data.Models
1212
{
13-
public class RoleEntity
13+
public class RoleEntity : IEntity
1414
{
1515
[Key]
1616
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
1717
public Guid Id { get; set; }
1818

1919
public string Name { get; set; }
20+
public bool AllPermissions { get; set; }
21+
public bool Immutable { get; set; }
2022

2123
public virtual ICollection<RolePermissionEntity> Permissions { get; set; } = new List<RolePermissionEntity>();
2224
}

Player.Api.Data/Data/Models/RolePermission.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Player.Api.Data.Data.Models
1111
{
12-
public class RolePermissionEntity
12+
public class RolePermissionEntity : IEntity
1313
{
1414
public RolePermissionEntity() { }
1515

Player.Api.Data/Data/Models/Team.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,26 @@
55
using System.Collections.Generic;
66
using System.ComponentModel.DataAnnotations;
77
using System.ComponentModel.DataAnnotations.Schema;
8-
using System.Text.Json.Serialization;
98

109
namespace Player.Api.Data.Data.Models
1110
{
12-
public class TeamEntity
11+
public class TeamEntity : IEntity
1312
{
1413
[Key]
1514
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
1615
public Guid Id { get; set; }
1716

1817
public string Name { get; set; }
1918

20-
public Guid? RoleId { get; set; }
21-
public RoleEntity Role { get; set; }
19+
public Guid RoleId { get; set; }
20+
public virtual TeamRoleEntity Role { get; set; }
2221

2322
public Guid ViewId { get; set; }
2423
public virtual ViewEntity View { get; set; }
2524

2625
public virtual ICollection<ApplicationInstanceEntity> Applications { get; set; } = new List<ApplicationInstanceEntity>();
2726
public virtual ICollection<TeamMembershipEntity> Memberships { get; set; } = new List<TeamMembershipEntity>();
28-
public virtual ICollection<TeamPermissionEntity> Permissions { get; set; } = new List<TeamPermissionEntity>();
27+
public virtual ICollection<TeamPermissionAssignmentEntity> Permissions { get; set; } = new List<TeamPermissionAssignmentEntity>();
2928

3029
public TeamEntity() { }
3130

@@ -34,7 +33,7 @@ public TeamEntity Clone()
3433
var entity = this.MemberwiseClone() as TeamEntity;
3534
entity.Applications = new List<ApplicationInstanceEntity>();
3635
entity.Memberships = new List<TeamMembershipEntity>();
37-
entity.Permissions = new List<TeamPermissionEntity>();
36+
entity.Permissions = new List<TeamPermissionAssignmentEntity>();
3837
entity.Id = Guid.Empty;
3938
entity.ViewId = Guid.Empty;
4039
entity.View = null;

0 commit comments

Comments
 (0)