Skip to content

Commit f104baf

Browse files
committed
Small changes
1 parent b1857d8 commit f104baf

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

.vscode/launch.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": ".NET Core Launch (auth)",
99
"type": "coreclr",
1010
"request": "launch",
11-
"preLaunchTask": "build",
11+
"preLaunchTask": "build (AuthWebApplication)",
1212
// If you have changed target frameworks, make sure to update the program path.
1313
"program": "${workspaceFolder}/server/AuthWebApplication/AuthWebApplication/bin/Debug/net5.0/AuthWebApplication.dll",
1414
"args": [],
@@ -20,7 +20,8 @@
2020
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
2121
},
2222
"env": {
23-
"ASPNETCORE_ENVIRONMENT": "Development"
23+
"ASPNETCORE_ENVIRONMENT": "Development",
24+
"ASPNETCORE_URLS": "https://localhost:5001;http://localhost:5000"
2425
},
2526
"sourceFileMap": {
2627
"/Views": "${workspaceFolder}/Views"
@@ -30,7 +31,7 @@
3031
"name": ".NET Core Launch (webapp)",
3132
"type": "coreclr",
3233
"request": "launch",
33-
"preLaunchTask": "build",
34+
"preLaunchTask": "build (WebApplication2)",
3435
// If you have changed target frameworks, make sure to update the program path.
3536
"program": "${workspaceFolder}/server/WebApplication2/WebApplication2/bin/Debug/net5.0/WebApplication2.dll",
3637
"args": [],
@@ -42,17 +43,12 @@
4243
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
4344
},
4445
"env": {
45-
"ASPNETCORE_ENVIRONMENT": "Development"
46+
"ASPNETCORE_ENVIRONMENT": "Development",
47+
"ASPNETCORE_URLS": "http://localhost:5002;https://localhost:5003"
4648
},
4749
"sourceFileMap": {
4850
"/Views": "${workspaceFolder}/Views"
4951
}
50-
},
51-
{
52-
"name": ".NET Core Attach",
53-
"type": "coreclr",
54-
"request": "attach",
55-
"processId": "${command:pickProcess}"
5652
}
5753
]
5854
}

.vscode/tasks.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "2.0.0",
33
"tasks": [
44
{
5-
"label": "build",
5+
"label": "build (AuthWebApplication)",
66
"command": "dotnet",
77
"type": "process",
88
"args": [
@@ -14,7 +14,19 @@
1414
"problemMatcher": "$msCompile"
1515
},
1616
{
17-
"label": "publish",
17+
"label": "build (WebApplication2)",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"build",
22+
"${workspaceFolder}/server/WebApplication2/WebApplication2/WebApplication2.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "publish (AuthWebApplication)",
1830
"command": "dotnet",
1931
"type": "process",
2032
"args": [
@@ -26,7 +38,7 @@
2638
"problemMatcher": "$msCompile"
2739
},
2840
{
29-
"label": "watch",
41+
"label": "watch (AuthWebApplication)",
3042
"command": "dotnet",
3143
"type": "process",
3244
"args": [

server/RedisLibrary/obj/AuthLibrary.csproj.nuget.dgspec.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@
7575
"assetTargetFallback": true,
7676
"warn": true,
7777
"frameworkReferences": {
78-
"Microsoft.AspNetCore.App": {
79-
"privateAssets": "none"
80-
},
8178
"Microsoft.NETCore.App": {
8279
"privateAssets": "all"
8380
}

server/RedisLibrary/obj/project.assets.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,9 +1273,6 @@
12731273
"assetTargetFallback": true,
12741274
"warn": true,
12751275
"frameworkReferences": {
1276-
"Microsoft.AspNetCore.App": {
1277-
"privateAssets": "none"
1278-
},
12791276
"Microsoft.NETCore.App": {
12801277
"privateAssets": "all"
12811278
}

server/WebApplication2/WebApplication2/Attributes/TokenAuthorizeAttribute.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ public void OnAuthorization(AuthorizationFilterContext context)
2424
var token = context.HttpContext.Request.Headers["Authorization"].ToString();
2525
try
2626
{
27-
HttpAuthorization(resource, token);
27+
HttpAuthorization(resource, token);
2828

2929
// GrpcAuthorization(token, resource);
30+
31+
//GoAuthorization(context, resource);
3032
}
3133
catch (HttpRequestException httpRequestException)
3234
{
@@ -44,6 +46,18 @@ public void OnAuthorization(AuthorizationFilterContext context)
4446

4547
}
4648

49+
private void GoAuthorization(AuthorizationFilterContext context, string resource)
50+
{
51+
var client = Factory.HttpClient;
52+
var user = context.HttpContext.User.Identity.Name;
53+
var claimsIdentity = context.HttpContext.User.Identities.First() as ClaimsIdentity;
54+
var claim = claimsIdentity.Claims.First(x => x.Type == JwtRegisteredClaimNames.Jti);
55+
var jti = claim.Value;
56+
var url = $"http://localhost:8080/api/AuthorizeToken?user={user}&resource={resource}&jti={jti}";
57+
var httpResponseMessage = client.GetAsync(url).GetAwaiter().GetResult();
58+
httpResponseMessage.EnsureSuccessStatusCode();
59+
}
60+
4761
private static string HttpAuthorization(string resource, string token)
4862
{
4963
var client = Factory.HttpClient;

0 commit comments

Comments
 (0)