Skip to content

Commit 847af23

Browse files
committed
401 Banner
1 parent 29b57d1 commit 847af23

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

MidlWare/MidlWare.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using VulnerableWebApplication.VLAIdentity;
33
using VulnerableWebApplication;
44
using Microsoft.IdentityModel.Tokens;
5+
using Microsoft.AspNetCore.Http;
6+
using System.Text;
57

68
namespace VulnerableWebApplication.MidlWare
79
{
@@ -42,6 +44,7 @@ Authentifie les utilisateurs
4244
*/
4345

4446
string authHeader = context.Request.Headers["Authorization"];
47+
string UnauthMsg = "Welcome to vulnerableLightApp. You are not authenticated. Source code is available at https://github.com/Aif4thah/VulnerableLightApp";
4548

4649
// URL Without Authentication
4750
var path = context.Request.Path.Value;
@@ -55,14 +58,17 @@ Authentifie les utilisateurs
5558
if (authHeader.IsNullOrEmpty() || !VLAIdentity.VLAIdentity.VulnerableValidateToken(authHeader, configuration["Secret"]))
5659
{
5760
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
61+
var bytes = Encoding.UTF8.GetBytes(UnauthMsg);
62+
context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
5863
return;
5964
}
6065

61-
6266
// Admin Authentication
6367
if (path.StartsWith("/Patch", StringComparison.OrdinalIgnoreCase) && (authHeader.IsNullOrEmpty() || !VLAIdentity.VLAIdentity.VulnerableAdminValidateToken(authHeader, configuration["Secret"])) )
6468
{
6569
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
70+
var bytes = Encoding.UTF8.GetBytes(UnauthMsg);
71+
context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
6672
return;
6773
}
6874

0 commit comments

Comments
 (0)