-
Notifications
You must be signed in to change notification settings - Fork 845
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VCST-1415: Add ability to use platform as OpenID authorization server (…
…#2809) Co-authored-by: Artem Dudarev <[email protected]>
- Loading branch information
1 parent
f637ccc
commit 8b2321f
Showing
19 changed files
with
769 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/VirtoCommerce.Platform.Web/ActionConstraints/HasFormValueAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Linq; | ||
using Microsoft.AspNetCore.Mvc.Abstractions; | ||
using Microsoft.AspNetCore.Mvc.ActionConstraints; | ||
using Microsoft.AspNetCore.Routing; | ||
|
||
namespace VirtoCommerce.Platform.Web.ActionConstraints; | ||
|
||
public sealed class HasFormValueAttribute : ActionMethodSelectorAttribute | ||
{ | ||
private readonly string _name; | ||
private readonly string[] _allowedMethods = ["POST"]; | ||
|
||
public HasFormValueAttribute(string name) | ||
{ | ||
_name = name; | ||
} | ||
|
||
public override bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action) | ||
{ | ||
var request = routeContext.HttpContext.Request; | ||
|
||
return _allowedMethods.Contains(request.Method, StringComparer.OrdinalIgnoreCase) && | ||
!string.IsNullOrEmpty(request.ContentType) && | ||
request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase) && | ||
!string.IsNullOrEmpty(request.Form[_name]); | ||
} | ||
} |
368 changes: 365 additions & 3 deletions
368
src/VirtoCommerce.Platform.Web/Controllers/Api/AuthorizationController.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/VirtoCommerce.Platform.Web/Model/AuthorizeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace VirtoCommerce.Platform.Web.Model; | ||
|
||
public class AuthorizeViewModel | ||
{ | ||
[Display(Name = "Application")] | ||
public string ApplicationName { get; set; } | ||
|
||
[Display(Name = "Scope")] | ||
public string Scope { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.