Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this seems to fix the legacy part of authentication, at least. #422

Merged
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
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/Altinn.Broker/bin/Debug/net8.0/Altinn.Broker.dll",
"program": "${workspaceFolder}/src/Altinn.Broker.API/bin/Debug/net8.0/Altinn.Broker.API.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Altinn.Broker",
"cwd": "${workspaceFolder}/src/Altinn.Broker.API",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Altinn.Broker/Altinn.Broker.csproj",
"${workspaceFolder}/src/Altinn.Broker.API/Altinn.Broker.API.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -19,7 +19,7 @@
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/Altinn.Broker/Altinn.Broker.csproj",
"${workspaceFolder}/src/Altinn.Broker.API/Altinn.Broker.API.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -33,7 +33,7 @@
"watch",
"run",
"--project",
"${workspaceFolder}/src/Altinn.Broker/Altinn.Broker.csproj"
"${workspaceFolder}/src/Altinn.Broker.API/Altinn.Broker.API.csproj"
],
"problemMatcher": "$msCompile"
}
Expand Down
12 changes: 6 additions & 6 deletions src/Altinn.Broker.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void ConfigureServices(IServiceCollection services, IConfiguration config

services.ConfigureHangfire();

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
services.AddAuthentication()
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options =>
{
var altinnOptions = new AltinnOptions();
Expand Down Expand Up @@ -162,11 +162,11 @@ static void ConfigureServices(IServiceCollection services, IConfiguration config
services.AddTransient<IAuthorizationHandler, ScopeAccessHandler>();
services.AddAuthorization(options =>
{
options.AddPolicy(AuthorizationConstants.Sender, policy => policy.AddRequirements(new ScopeAccessRequirement(AuthorizationConstants.SenderScope)));
options.AddPolicy(AuthorizationConstants.Recipient, policy => policy.AddRequirements(new ScopeAccessRequirement(AuthorizationConstants.RecipientScope)));
options.AddPolicy(AuthorizationConstants.SenderOrRecipient, policy => policy.AddRequirements(new ScopeAccessRequirement([AuthorizationConstants.SenderScope, AuthorizationConstants.RecipientScope])));
options.AddPolicy(AuthorizationConstants.Legacy, policy => policy.AddRequirements(new ScopeAccessRequirement(AuthorizationConstants.LegacyScope)));
options.AddPolicy(AuthorizationConstants.ServiceOwner, policy => policy.AddRequirements(new ScopeAccessRequirement(AuthorizationConstants.ServiceOwnerScope)));
options.AddPolicy(AuthorizationConstants.Sender, policy => policy.AddRequirements(new ScopeAccessRequirement(AuthorizationConstants.SenderScope)).AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme));
options.AddPolicy(AuthorizationConstants.Recipient, policy => policy.AddRequirements(new ScopeAccessRequirement(AuthorizationConstants.RecipientScope)).AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme));
options.AddPolicy(AuthorizationConstants.SenderOrRecipient, policy => policy.AddRequirements(new ScopeAccessRequirement([AuthorizationConstants.SenderScope, AuthorizationConstants.RecipientScope])).AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme));
options.AddPolicy(AuthorizationConstants.Legacy, policy => policy.AddRequirements(new ScopeAccessRequirement(AuthorizationConstants.LegacyScope)).AddAuthenticationSchemes(AuthorizationConstants.Legacy));
options.AddPolicy(AuthorizationConstants.ServiceOwner, policy => policy.AddRequirements(new ScopeAccessRequirement(AuthorizationConstants.ServiceOwnerScope)).AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme));
});

services.Configure<KestrelServerOptions>(options =>
Expand Down