Skip to content

Commit 73d1ee7

Browse files
authored
Credit page (#588)
* updated for mtsinai examples * added missing user group and role tables to leafdb.schema.sql script * upgraded dependencies, added migration script, bumped versions, switched to dotnet core 6 * updated client deps
1 parent a54f777 commit 73d1ee7

26 files changed

Lines changed: 685 additions & 345 deletions

src/db/build/LeafDB.Schema.sql

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,43 @@ CREATE TABLE [rela].[QueryConceptDependency](
13641364
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
13651365
) ON [PRIMARY]
13661366
GO
1367+
/****** Object: Table [auth].[UserRole] Script Date: ******/
1368+
SET ANSI_NULLS ON
1369+
GO
1370+
SET QUOTED_IDENTIFIER ON
1371+
GO
1372+
CREATE TABLE [auth].[UserRole](
1373+
[ScopedIdentity] [nvarchar](200) NOT NULL,
1374+
[IsUser] [bit] NOT NULL,
1375+
[IsAdmin] [bit] NOT NULL,
1376+
[IsSuper] [bit] NOT NULL,
1377+
[IsIdentified] [bit] NOT NULL,
1378+
[IsFederated] [bit] NOT NULL,
1379+
[Created] datetime NOT NULL,
1380+
[Updated] datetime NOT NULL
1381+
CONSTRAINT [PK__UserRole] PRIMARY KEY CLUSTERED
1382+
(
1383+
[ScopedIdentity] ASC
1384+
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
1385+
) ON [PRIMARY]
1386+
GO
1387+
/****** Object: Table [auth].[UserGroup] Script Date: ******/
1388+
SET ANSI_NULLS ON
1389+
GO
1390+
SET QUOTED_IDENTIFIER ON
1391+
GO
1392+
CREATE TABLE [auth].[UserGroup](
1393+
[ScopedIdentity] [nvarchar](200) NOT NULL,
1394+
[GroupName] [nvarchar](200) NOT NULL,
1395+
[Created] datetime NOT NULL,
1396+
[Updated] datetime NOT NULL
1397+
CONSTRAINT [PK__UserGroup] PRIMARY KEY CLUSTERED
1398+
(
1399+
[ScopedIdentity] ASC,
1400+
[GroupName] ASC
1401+
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
1402+
) ON [PRIMARY]
1403+
GO
13671404
/****** Object: Table [rela].[QueryDependency] Script Date: ******/
13681405
SET ANSI_NULLS ON
13691406
GO
@@ -9061,9 +9098,32 @@ BEGIN
90619098

90629099
EXEC network.sp_GetEndpoints;
90639100
END
9101+
GO
90649102

90659103

9104+
-- =======================================
9105+
-- Author: Nic Dobbins
9106+
-- Create date: 2021/10/19
9107+
-- Description: Gets user roles
9108+
-- =======================================
9109+
CREATE PROCEDURE [auth].[sp_GetUserGroupsAndRoles]
9110+
@scopedId nvarchar(200)
9111+
AS
9112+
BEGIN
9113+
SET NOCOUNT ON
9114+
9115+
-- Roles
9116+
SELECT IsUser, IsAdmin, IsSuper, IsIdentified, IsFederated
9117+
FROM [auth].[UserRole] AS R
9118+
WHERE R.ScopedIdentity = @scopedId
90669119

9120+
-- Groups
9121+
SELECT GroupName
9122+
FROM [auth].[UserGroup] AS G
9123+
WHERE G.ScopedIdentity = @scopedId
9124+
9125+
END
9126+
GO
90679127

90689128

90699129

src/db/migration/3.11.1__3.11.2.sql

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,29 @@ IF COLUMNPROPERTY(OBJECT_ID('app.DemographicQuery'), 'ColumnNamesJson', 'ColumnI
1212
BEGIN
1313
ALTER TABLE app.DemographicQuery
1414
ADD [ColumnNamesJson] NVARCHAR(MAX) NULL
15+
END
16+
GO
1517

18+
IF (SELECT ColumnNamesJson FROM app.DemographicQuery) IS NULL
19+
BEGIN
1620
UPDATE app.DemographicQuery
17-
SET [ColumnNamesJson] = '{}'
21+
SET [ColumnNamesJson] = '{}'
1822
END
1923
GO
2024

25+
2126
/**
2227
* Add [IsDefault] to app.DatasetQuery
2328
*/
2429
IF COLUMNPROPERTY(OBJECT_ID('app.DatasetQuery'), 'IsDefault', 'ColumnId') IS NULL
2530
BEGIN
2631
ALTER TABLE app.DatasetQuery
2732
ADD [IsDefault] BIT NULL
33+
END
34+
GO
2835

36+
IF (SELECT COUNT(*) FROM app.DatasetQuery WHERE IsDefault IS NULL) > 0
37+
BEGIN
2938
UPDATE app.DatasetQuery
3039
SET [IsDefault] = 0
3140
END
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Update version
3+
*/
4+
UPDATE ref.[Version]
5+
SET [Version] = '3.11.3'
6+
GO

src/server/API/API.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFramework>net6.0</TargetFramework>
44
<!-- <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> -->
55
<TieredCompilation>true</TieredCompilation>
66
<ReleaseVersion>3.1</ReleaseVersion>
@@ -27,22 +27,22 @@
2727
<Folder Include="DTO\Notification\" />
2828
</ItemGroup>
2929
<ItemGroup>
30-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
30+
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.2">
3131
<PrivateAssets>all</PrivateAssets>
3232
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3333
</PackageReference>
3434
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
3535
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
36-
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
36+
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
3737
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
3838
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
3939
<PackageReference Include="Microsoft.AspNetCore.App">
4040
<PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
4141
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
4242
</PackageReference>
4343
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
44-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
45-
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.7.1" />
44+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.29.0" />
45+
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.29.0" />
4646
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.18" />
4747
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
4848
</ItemGroup>

src/server/API/Controllers/ConfigController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,15 @@ public ActionResult<ConfigDTO> Get()
6363
Attestation = new AttestationConfigDTO
6464
{
6565
Enabled = attestationOptions.Enabled,
66+
SkipModeSelection = attestationOptions.SkipModeSelection,
6667
Text = attestationOptions.Text,
67-
Type = attestationOptions.Type
68+
Type = attestationOptions.Type,
69+
Credits = new AttestationConfigDTO.AttestationCreditsDTO
70+
{
71+
Enabled = attestationOptions.Credits.Enabled,
72+
Logos = attestationOptions.Credits.Logos,
73+
Text = attestationOptions.Credits.Text
74+
}
6875
},
6976
Cohort = new CohortConfigDTO
7077
{

src/server/API/DTO/Config/ConfigDTO.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,18 @@ public class CohortConfigDTO
5252
public class AttestationConfigDTO
5353
{
5454
public bool Enabled { get; set; }
55+
public bool SkipModeSelection { get; set; }
5556
public string[] Text { get; set; }
5657
public CustomAttestationType Type { get; set; }
58+
59+
public AttestationCreditsDTO Credits { get; set; }
60+
61+
public class AttestationCreditsDTO
62+
{
63+
public bool Enabled { get; set; }
64+
public string[] Logos { get; set; }
65+
public string Text { get; set; }
66+
}
5767
}
5868

5969
public class ClientOptionsDTO

src/server/API/Options/Config.Attestation.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ public static class Attestation
1515
public const string Enabled = @"Attestation:Enabled";
1616
public const string Type = @"Attestation:Type";
1717
public const string Text = @"Attestation:Text";
18+
public const string SkipModeSelection = "Attestation:SkipModeSelection";
19+
20+
public static class Credits
21+
{
22+
public const string Enabled = @"Attestation:Credits:Enabled";
23+
public const string Text = @"Attestation:Credits:Text";
24+
public const string Logos = @"Attestation:Credits:Logos";
25+
}
1826
}
1927
}
2028
}

src/server/API/Options/StartupExtensions.Options.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,29 @@ static IServiceCollection ConfigureAttestationOptions(this IServiceCollection se
162162

163163
if (attest.Enabled)
164164
{
165+
attest.SkipModeSelection = config.GetValue<bool>(Config.Attestation.SkipModeSelection);
165166
attest.WithAttestationType(config.GetValue<string>(Config.Attestation.Type));
166167
if (attest.Type != CustomAttestationType.None)
167168
{
168169
attest.Text = config.GetSection(Config.Attestation.Text).Get<string[]>();
169170
}
170171
}
172+
173+
var hasCredits = config.TryGetValue<bool>(Config.Attestation.Credits.Enabled, out bool creditsEnabled);
174+
if (hasCredits && creditsEnabled)
175+
{
176+
attest.Credits.Enabled = true;
177+
attest.Credits.Text = config.GetValue<string>(Config.Attestation.Credits.Text);
178+
attest.Credits.Logos = config.GetSection(Config.Attestation.Credits.Logos).Get<string[]>();
179+
}
180+
171181
services.Configure<AttestationOptions>(opts =>
172182
{
173183
opts.Enabled = attest.Enabled;
184+
opts.SkipModeSelection = attest.SkipModeSelection;
174185
opts.Text = attest.Text;
175186
opts.Type = attest.Type;
187+
opts.Credits = attest.Credits;
176188
});
177189

178190
return services;

src/server/API/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
}
5959
},
6060
"Attestation": {
61-
"Enabled": false
61+
"Enabled": true
6262
},
6363
"Compiler": {
6464
"Alias": "@",

src/server/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>3.11.2</VersionPrefix>
3+
<VersionPrefix>3.11.3</VersionPrefix>
44
</PropertyGroup>
55
</Project>

0 commit comments

Comments
 (0)