Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion IdentityServer/v7/Apis/SimpleApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

builder.Services.AddControllers();

// this API will accept any access token from the authority
// Attention: This API will accept any access token from the authority in this configuration
builder.Services.AddAuthentication("token")
.AddJwtBearer("token", options =>
{
Expand All @@ -32,12 +32,19 @@
options.MapInboundClaims = false;
});

// To require a scope, use a policy like this and apply it
builder.Services.AddAuthorization(options =>
{
options.AddPolicy("SimpleApi", p => p.RequireClaim("scope", "SimpleApi"));
});

var app = builder.Build();

app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();

app.MapControllers().RequireAuthorization();
//app.MapControllers().RequireAuthorization("SimpleApi");

app.Run();
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"Self": {
"SelfHost": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5002",
"applicationUrl": "https://localhost:5003",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ namespace ConsoleDcrClient;
public class Constants
{
public const string Authority = "https://localhost:5001";
public const string SimpleApi = "https://localhost:6001/";
public const string SimpleApi = "https://localhost:5002/";
public const string ConfigurationApi = "https://localhost:5003";
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static async Task<DynamicClientRegistrationResponse> RegisterClient(string acces

var request = new DynamicClientRegistrationRequest
{
Address = "https://localhost:5002/connect/dcr",
Address = $"{Constants.ConfigurationApi}/connect/dcr",
Document = new DynamicClientRegistrationDocument
{

Expand Down Expand Up @@ -77,7 +77,7 @@ static async Task<TokenResponse> RequestTokenAsync(string clientId = "client", s
{
var client = new HttpClient();

var disco = await client.GetDiscoveryDocumentAsync("https://localhost:5001");
var disco = await client.GetDiscoveryDocumentAsync(Constants.Authority);
if (disco.IsError) throw new Exception(disco.Error);

var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
Expand Down
12 changes: 6 additions & 6 deletions IdentityServer/v7/Configuration/Permissions/Permissions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Configuration", "Configurat
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleDcrClient", "ConsoleDcrClient\ConsoleDcrClient.csproj", "{D134466E-58AE-4787-984B-FB6F95EEA969}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleApi", "SimpleApi\SimpleApi.csproj", "{CCAA779F-8528-4351-8333-80B60A7C4FAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer", "..\IdentityServerHost\IdentityServer.csproj", "{075FD8FE-6A12-4121-9163-F2A48001F37B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleApi", "..\..\Apis\SimpleApi\SimpleApi.csproj", "{52E6BB46-1B26-431D-B13E-D58734BFF1B2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -28,13 +28,13 @@ Global
{D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Release|Any CPU.Build.0 = Release|Any CPU
{CCAA779F-8528-4351-8333-80B60A7C4FAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCAA779F-8528-4351-8333-80B60A7C4FAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCAA779F-8528-4351-8333-80B60A7C4FAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCAA779F-8528-4351-8333-80B60A7C4FAC}.Release|Any CPU.Build.0 = Release|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|Any CPU.Build.0 = Release|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

This file was deleted.

44 changes: 0 additions & 44 deletions IdentityServer/v7/Configuration/Permissions/SimpleApi/Program.cs

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5002",
"launchBrowser": false,
"applicationUrl": "https://localhost:5003",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ namespace ConsoleDcrClient;
public class Constants
{
public const string Authority = "https://localhost:5001";
public const string SimpleApi = "https://localhost:6001/";
public const string SimpleApi = "https://localhost:5002/";
public const string ConfigurationApi = "https://localhost:5003";
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static async Task<DynamicClientRegistrationResponse> RegisterClient(string acces

var request = new DynamicClientRegistrationRequest
{
Address = "https://localhost:5002/connect/dcr",
Address = $"{Constants.ConfigurationApi}/connect/dcr",
Document = new DynamicClientRegistrationDocument
{

Expand All @@ -81,7 +81,7 @@ static async Task<TokenResponse> RequestTokenAsync(string clientId, string clien
{
var client = new HttpClient();

var disco = await client.GetDiscoveryDocumentAsync("https://localhost:5001");
var disco = await client.GetDiscoveryDocumentAsync(Constants.Authority);
if (disco.IsError) throw new Exception(disco.Error);

var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Configuration", "Configurat
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleDcrClient", "ConsoleDcrClient\ConsoleDcrClient.csproj", "{D134466E-58AE-4787-984B-FB6F95EEA969}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleApi", "SimpleApi\SimpleApi.csproj", "{238947E4-9433-4CC5-B4A6-0E8EC935A9F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer", "..\IdentityServerHost\IdentityServer.csproj", "{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleApi", "..\..\Apis\SimpleApi\SimpleApi.csproj", "{1F141D4D-C27D-4A94-B518-80369AFE33E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -28,13 +28,13 @@ Global
{D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Release|Any CPU.Build.0 = Release|Any CPU
{238947E4-9433-4CC5-B4A6-0E8EC935A9F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{238947E4-9433-4CC5-B4A6-0E8EC935A9F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{238947E4-9433-4CC5-B4A6-0E8EC935A9F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{238947E4-9433-4CC5-B4A6-0E8EC935A9F6}.Release|Any CPU.Build.0 = Release|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Release|Any CPU.Build.0 = Release|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading