diff options
Diffstat (limited to 'VPNAuth.Server/Pages/Auth.cshtml.cs')
-rw-r--r-- | VPNAuth.Server/Pages/Auth.cshtml.cs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/VPNAuth.Server/Pages/Auth.cshtml.cs b/VPNAuth.Server/Pages/Auth.cshtml.cs index bdcbc59..ea648cb 100644 --- a/VPNAuth.Server/Pages/Auth.cshtml.cs +++ b/VPNAuth.Server/Pages/Auth.cshtml.cs @@ -7,6 +7,7 @@ namespace VPNAuth.Server.Pages; public class Auth : PageModel { public Config Config; + public ConfigApp? ConfApp; public ConfigUser? User; public bool ValidRequest; public EntityEntry<AuthRequest>? RequestEntry; @@ -23,12 +24,14 @@ public class Auth : PageModel public void OnGet() { Config = Config.Read(); + ConfApp = Config.FindApp(Request.Query["client_id"]); User = HttpContext.GetUser(); ValidRequest = RequiredQueryParams.All(key => Request.Query.ContainsKey(key)) - && Config.FindApp(Request.Query["client_id"]!) != null + && ConfApp != null && Request.Query["code_challenge_method"] == "S256" - && User != null; + && User != null + && (ConfApp.AllowedUsers == null || ConfApp.AllowedUsers!.Contains(User.Username!)); RequestEntry = null; @@ -44,7 +47,8 @@ public class Auth : PageModel Scopes = Request.Query["scope"].ToString().Split(" ").ToList(), CodeChallenge = Request.Query["code_challenge"]!, CodeChallengeMethod = Request.Query["code_challenge_method"]!, - Accepted = false + Accepted = false, + Username = User!.Username! }); db.SaveChanges(); } |