Skip to content

Commit

Permalink
this seems to fix the legacy part of authentication, at least. (#422)
Browse files Browse the repository at this point in the history
Co-authored-by: tsh <acn-thage@ai-dev.no>
  • Loading branch information
tomshag and tsh authored May 6, 2024
1 parent 824e3c2 commit 4877f47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
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

0 comments on commit 4877f47

Please sign in to comment.