-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Shoogn/dev
Dev
- Loading branch information
Showing
29 changed files
with
646 additions
and
175 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
namespace OAuth20.Server | ||
{ | ||
public static class Constants | ||
{ | ||
public static class ChallengeMethod | ||
{ | ||
public static string Plain = "plain"; | ||
public static string SHA256 = "S256"; | ||
} | ||
|
||
public static class OpenIdConnectScopes | ||
{ | ||
public static string OpenId = "openid"; | ||
public static string Profile = "profile"; | ||
public static string Email = "email"; | ||
public static string Address = "address"; | ||
public static string Phone = "phone"; | ||
} | ||
|
||
public static class TokenTypes | ||
{ | ||
public const string JWTAcceseccToken = "Access_Token"; | ||
public const string JWTIdentityToken = "Idp_Token"; | ||
public const string AccessAndIdpToken = "Access_Idp_Token"; | ||
} | ||
|
||
|
||
public static class TokenTypeHints | ||
{ | ||
public const string AccessToken = "access_token"; | ||
public const string RefreshToken = "refresh_token"; | ||
} | ||
|
||
public static class Statuses | ||
{ | ||
public const string InActive = "inactive"; | ||
public const string Revoked = "revoked"; | ||
public const string Valid = "valid"; | ||
} | ||
|
||
public static class ContentTypeSupported | ||
{ | ||
public const string XwwwFormUrlEncoded = "application/x-www-form-urlencoded"; | ||
} | ||
|
||
public static class AuthenticatedRequestScheme | ||
{ | ||
public const string AuthorizationRequestHeader = "Bearer"; | ||
public const string FormEncodedBodyParameter = "access_token"; | ||
public const string UriQueryParameter = "access_token"; | ||
} | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
Server/src/OAuth20.Server/Controllers/UserInfoController.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,29 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Cors; | ||
using Microsoft.AspNetCore.Mvc; | ||
using OAuth20.Server.Services; | ||
using System.Threading.Tasks; | ||
|
||
namespace OAuth20.Server.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
[EnableCors("UserInfoPolicy")] | ||
[ApiController] | ||
[AllowAnonymous] | ||
public class UserInfoController : ControllerBase | ||
{ | ||
private readonly IUserInfoService _userInfoService; | ||
public UserInfoController(IUserInfoService userInfoService) | ||
{ | ||
_userInfoService = userInfoService; | ||
} | ||
|
||
[HttpGet("GetUserInfo")] | ||
|
||
public async Task<IActionResult> GetUserInfo() | ||
{ | ||
var userInfo = await _userInfoService.GetUserInfoAsync(); | ||
return Ok(userInfo); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Server/src/OAuth20.Server/Enumeration/BearerTokenUsageTypeEnum.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,19 @@ | ||
/* | ||
GNU GENERAL PUBLIC LICENSE | ||
Version 3, 29 June 2007 | ||
Copyright (C) 2022 Mohammed Ahmed Hussien babiker Free Software Foundation, Inc. <https://fsf.org/> | ||
Everyone is permitted to copy and distribute verbatim copies | ||
of this license document, but changing it is not allowed. | ||
*/ | ||
|
||
namespace OAuth20.Server.Enumeration; | ||
|
||
/// <summary> | ||
/// For more information see the <see cref="https://www.rfc-editor.org/info/rfc6750"/> | ||
/// </summary> | ||
public enum BearerTokenUsageTypeEnum : byte | ||
{ | ||
AuthorizationRequestHeader, | ||
FormEncodedBodyParameter, | ||
UriQueryParameter | ||
} |
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
31 changes: 31 additions & 0 deletions
31
Server/src/OAuth20.Server/OAuthResponse/UserInfoResponse.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,31 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace OAuth20.Server.OAuthResponse | ||
{ | ||
public class UserInfoResponse | ||
{ | ||
public bool Succeeded { get; set; } | ||
public string Error { get; set; } = string.Empty; | ||
|
||
public string ErrorDescription { get; set; } | ||
public bool HasError => !string.IsNullOrEmpty(Error); | ||
|
||
|
||
/// <summary> | ||
/// Returned result as json. | ||
/// </summary> | ||
public string Claims { get; set; } | ||
|
||
[JsonPropertyName("sub")] | ||
public string Sub { get; set; } | ||
|
||
[JsonPropertyName("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonPropertyName("email")] | ||
public string Email { get; set; } | ||
|
||
[JsonPropertyName("email_verified")] | ||
public bool EmailVerified { 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
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.