last ...
This commit is contained in:
@@ -1,197 +1,205 @@
|
|||||||
using xExceptions.Attributes;
|
using xExceptions.Attributes;
|
||||||
|
|
||||||
namespace xIdentityService.Constants {
|
namespace xIdentityService.Constants
|
||||||
public enum XApiAccountEndpoint {
|
{
|
||||||
|
public enum XApiAccountEndpoint
|
||||||
|
{
|
||||||
//
|
//
|
||||||
#region Authentication ...
|
#region Authentication ...
|
||||||
[StringValue ("Account/DiscoveryDocument")]
|
[StringValue("Account/DiscoveryDocument")]
|
||||||
DiscoveryDocument,
|
DiscoveryDocument,
|
||||||
|
|
||||||
[StringValue ("Account/RequestScopeAccessToken")]
|
[StringValue("Account/RequestScopeAccessToken")]
|
||||||
RequestScopeAccessToken,
|
RequestScopeAccessToken,
|
||||||
|
|
||||||
[StringValue ("Account/Authenticate")]
|
[StringValue("Account/Authenticate")]
|
||||||
Authenticate,
|
Authenticate,
|
||||||
|
|
||||||
[StringValue ("Account/Login")]
|
[StringValue("Account/Login")]
|
||||||
Login,
|
Login,
|
||||||
|
|
||||||
[StringValue ("Account/RefreshTokens")]
|
[StringValue("Account/RefreshTokens")]
|
||||||
RefreshTokens,
|
RefreshTokens,
|
||||||
|
|
||||||
[StringValue ("Account/ChangePassword")]
|
[StringValue("Account/ChangePassword")]
|
||||||
ChangePassword,
|
ChangePassword,
|
||||||
|
|
||||||
[StringValue ("Account/ResetPassword")]
|
[StringValue("Account/ResetPassword")]
|
||||||
ResetPassword,
|
ResetPassword,
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Proile ...
|
#region Proile ...
|
||||||
[StringValue ("Account/Profile/{ids}/GetNames")]
|
[StringValue("Account/Profile/{ids}/GetNames")]
|
||||||
GetNames,
|
GetNames,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/GetNameIds")]
|
[StringValue("Account/Profile/GetNameIds")]
|
||||||
GetNameIds,
|
GetNameIds,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/{userSelectByParam}")]
|
[StringValue("Account/Profile/{userSelectByParam}")]
|
||||||
GetProfile,
|
GetProfile,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/Query")]
|
[StringValue("Account/Profile/Query")]
|
||||||
QueryProfiles,
|
QueryProfiles,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/Avatars/Query/{userSelectByParam}")]
|
[StringValue("Account/Profile/Avatars/Query/{userSelectByParam}")]
|
||||||
QueryAvatars,
|
QueryAvatars,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/Update/{userSelectByParam}")]
|
[StringValue("Account/Profile/Update/{userSelectByParam}")]
|
||||||
UpdateProfile,
|
UpdateProfile,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/{userSelectByParam}")]
|
[StringValue("Account/Profile/{userSelectByParam}")]
|
||||||
FullUpdateProfile,
|
FullUpdateProfile,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/Avatar")]
|
[StringValue("Account/Profile/Avatar")]
|
||||||
AddAvatar,
|
AddAvatar,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/Avatars")]
|
[StringValue("Account/Profile/Avatars")]
|
||||||
AddAvatars,
|
AddAvatars,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/Avatars/{ids}")]
|
[StringValue("Account/Profile/Avatars/{ids}")]
|
||||||
RemoveAvatars,
|
RemoveAvatars,
|
||||||
|
|
||||||
[StringValue ("Account/Profile/Avatars/{id}/Set")]
|
[StringValue("Account/Profile/Avatars/{id}/Set")]
|
||||||
SetAvatar,
|
SetAvatar,
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Registration ...
|
#region Registration ...
|
||||||
[StringValue ("Account/CanRegisterUserName/{userName}")]
|
[StringValue("Account/CanRegisterUserName/{userName}")]
|
||||||
CanRegisterUserName,
|
CanRegisterUserName,
|
||||||
|
|
||||||
[StringValue ("Account/CanRegisterMobileNumber/{mobileNumber}")]
|
[StringValue("Account/CanRegisterMobileNumber/{mobileNumber}")]
|
||||||
CanRegisterMobileNumber,
|
CanRegisterMobileNumber,
|
||||||
|
|
||||||
[StringValue ("Account/CanRegisterEmail/{email}")]
|
[StringValue("Account/CanRegisterEmail/{email}")]
|
||||||
CanRegisterEmail,
|
CanRegisterEmail,
|
||||||
|
|
||||||
[StringValue ("Account/IsConfirmedEmail")]
|
[StringValue("Account/IsConfirmedEmail")]
|
||||||
IsConfirmedEmail,
|
IsConfirmedEmail,
|
||||||
|
|
||||||
[StringValue ("Account/IsConfirmedMobile")]
|
[StringValue("Account/IsConfirmedMobile")]
|
||||||
IsConfirmedMobile,
|
IsConfirmedMobile,
|
||||||
|
|
||||||
[StringValue ("Account/ConfirmRegistration")]
|
[StringValue("Account/ConfirmRegistration")]
|
||||||
ConfirmRegistration,
|
ConfirmRegistration,
|
||||||
|
|
||||||
[StringValue ("Account/ConfirmMobileNumber")]
|
[StringValue("Account/ConfirmMobileNumber")]
|
||||||
ConfirmMobileNumber,
|
ConfirmMobileNumber,
|
||||||
|
|
||||||
[StringValue ("Account/ConfirmEmailAddress")]
|
[StringValue("Account/ConfirmEmailAddress")]
|
||||||
ConfirmEmailAddress,
|
ConfirmEmailAddress,
|
||||||
|
|
||||||
[StringValue ("Account/RequestConfirmMobile")]
|
[StringValue("Account/RequestConfirmMobile")]
|
||||||
RequestConfirmMobile,
|
RequestConfirmMobile,
|
||||||
|
|
||||||
[StringValue ("Account/RequestConfirmEmail")]
|
[StringValue("Account/RequestConfirmEmail")]
|
||||||
RequestConfirmEmail,
|
RequestConfirmEmail,
|
||||||
|
|
||||||
[StringValue ("Account/RequestResetPassword")]
|
[StringValue("Account/RequestResetPassword")]
|
||||||
RequestResetPassword,
|
RequestResetPassword,
|
||||||
|
|
||||||
[StringValue ("Account/RequestConfirmRegistration")]
|
[StringValue("Account/RequestConfirmRegistration")]
|
||||||
RequestConfirmRegistration,
|
RequestConfirmRegistration,
|
||||||
|
|
||||||
[StringValue ("Account/InviteUser")]
|
[StringValue("Account/InviteUser")]
|
||||||
InviteUser,
|
InviteUser,
|
||||||
|
|
||||||
[StringValue ("Account/RequestRegistration")]
|
[StringValue("Account/RequestRegistration")]
|
||||||
RequestRegistration,
|
RequestRegistration,
|
||||||
|
|
||||||
[StringValue ("Account/AddAccountInfo")]
|
[StringValue("Account/AddAccountInfo")]
|
||||||
AddAccountInfo,
|
AddAccountInfo,
|
||||||
|
|
||||||
[StringValue ("Account/AttachProfileImage")]
|
[StringValue("Account/AttachProfileImage")]
|
||||||
AttachProfileImage,
|
AttachProfileImage,
|
||||||
|
|
||||||
[StringValue ("Account/FinishRegistration")]
|
[StringValue("Account/FinishRegistration")]
|
||||||
FinishRegistration,
|
FinishRegistration,
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Friendship ...
|
#region Friendship ...
|
||||||
[StringValue ("Account/Friendship/{destUser}/Follow")]
|
[StringValue("Account/Friendship/{destUser}/Follow")]
|
||||||
Follow,
|
Follow,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/Cancel")]
|
[StringValue("Account/Friendship/{destUser}/Cancel")]
|
||||||
Cancel,
|
Cancel,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/UnFollowFollower")]
|
[StringValue("Account/Friendship/{destUser}/UnFollowFollower")]
|
||||||
UnFollowFollower,
|
UnFollowFollower,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/UnFollowFollowing")]
|
[StringValue("Account/Friendship/{destUser}/UnFollowFollowing")]
|
||||||
UnFollowFollowing,
|
UnFollowFollowing,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/Block")]
|
[StringValue("Account/Friendship/{destUser}/Block")]
|
||||||
Block,
|
Block,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/UnBlock")]
|
[StringValue("Account/Friendship/{destUser}/UnBlock")]
|
||||||
UnBlock,
|
UnBlock,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/AcceptRequest")]
|
[StringValue("Account/Friendship/{destUser}/AcceptRequest")]
|
||||||
AcceptRequest,
|
AcceptRequest,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/RejectRequest")]
|
[StringValue("Account/Friendship/{destUser}/RejectRequest")]
|
||||||
RejectRequest,
|
RejectRequest,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/IsFollower")]
|
[StringValue("Account/Friendship/{destUser}/IsFollower")]
|
||||||
IsFollower,
|
IsFollower,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/FollowerState")]
|
[StringValue("Account/Friendship/{destUser}/FollowerState")]
|
||||||
FollowerState,
|
FollowerState,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/Follower")]
|
[StringValue("Account/Friendship/{destUser}/Follower")]
|
||||||
Follower,
|
Follower,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/Followers")]
|
[StringValue("Account/Friendship/Followers")]
|
||||||
Followers,
|
Followers,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/AllFollowers")]
|
[StringValue("Account/Friendship/AllFollowers")]
|
||||||
AllFollowers,
|
AllFollowers,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/IsFollowing")]
|
[StringValue("Account/Friendship/{destUser}/IsFollowing")]
|
||||||
IsFollowing,
|
IsFollowing,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/FollowingState")]
|
[StringValue("Account/Friendship/{destUser}/FollowingState")]
|
||||||
FollowingState,
|
FollowingState,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/Following")]
|
[StringValue("Account/Friendship/{destUser}/Following")]
|
||||||
Following,
|
Following,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/Followings")]
|
[StringValue("Account/Friendship/Followings")]
|
||||||
Followings,
|
Followings,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/AllFollowings")]
|
[StringValue("Account/Friendship/AllFollowings")]
|
||||||
AllFollowings,
|
AllFollowings,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/FollowingsList")]
|
[StringValue("Account/Friendship/FollowingsList")]
|
||||||
FollowingsList,
|
FollowingsList,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/FollowersList")]
|
[StringValue("Account/Friendship/FollowersList")]
|
||||||
FollowersList,
|
FollowersList,
|
||||||
|
|
||||||
[StringValue ("Account/Friendship/{destUser}/FriendshipInfo")]
|
[StringValue("Account/Friendship/{destUser}/FriendshipInfo")]
|
||||||
FriendshipInfo,
|
FriendshipInfo,
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Admin ...
|
#region Admin ...
|
||||||
[StringValue ("Account/Ban")]
|
[StringValue("Account/Ban")]
|
||||||
Ban,
|
Ban,
|
||||||
|
|
||||||
[StringValue ("Account/UnBan")]
|
[StringValue("Account/UnBan")]
|
||||||
UnBan,
|
UnBan,
|
||||||
|
|
||||||
[StringValue ("Account/IsBanned/{userSelectByParam}")]
|
[StringValue("Account/IsBanned/{userSelectByParam}")]
|
||||||
IsBanned,
|
IsBanned,
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Open Actions ...
|
||||||
|
[StringValue("Account/GetUserInfo")]
|
||||||
|
GetUserInfo,
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,9 @@ namespace xIdentityService.Constants {
|
|||||||
[StringValue ("actionToken")]
|
[StringValue ("actionToken")]
|
||||||
XActionToken,
|
XActionToken,
|
||||||
|
|
||||||
|
[StringValue ("request")]
|
||||||
|
XRequest,
|
||||||
|
|
||||||
[StringValue ("scope")]
|
[StringValue ("scope")]
|
||||||
XScope,
|
XScope,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,18 @@ using xIdentityModels.Models;
|
|||||||
using xIdentityModels.Navigations;
|
using xIdentityModels.Navigations;
|
||||||
using xModels.Dtos;
|
using xModels.Dtos;
|
||||||
|
|
||||||
namespace xIdentityService.Interfaces {
|
namespace xIdentityService.Interfaces
|
||||||
public partial interface IXIdentityProvider {
|
{
|
||||||
|
public partial interface IXIdentityProvider
|
||||||
|
{
|
||||||
//
|
//
|
||||||
string BaseUrl { get; }
|
string BaseUrl { get; }
|
||||||
string RevisionSecretKey { get; }
|
string RevisionSecretKey { get; }
|
||||||
|
IXSecurityProvider SecurityProvider { get; }
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Tools ...
|
#region Tools ...
|
||||||
string GetUserSelectByParam (
|
string GetUserSelectByParam(
|
||||||
XActionRequest model,
|
XActionRequest model,
|
||||||
bool forceNotNull = true,
|
bool forceNotNull = true,
|
||||||
ICollection<XUserSelectBy> excludes = null
|
ICollection<XUserSelectBy> excludes = null
|
||||||
@@ -27,7 +30,7 @@ namespace xIdentityService.Interfaces {
|
|||||||
|
|
||||||
//
|
//
|
||||||
#region Tools ...
|
#region Tools ...
|
||||||
Task<T> RunRestRequest<T> (
|
Task<T> RunRestRequest<T>(
|
||||||
RestClient client,
|
RestClient client,
|
||||||
RestRequest request,
|
RestRequest request,
|
||||||
XHttpMethod method,
|
XHttpMethod method,
|
||||||
@@ -37,15 +40,15 @@ namespace xIdentityService.Interfaces {
|
|||||||
|
|
||||||
//
|
//
|
||||||
#region Authentication ...
|
#region Authentication ...
|
||||||
Task<DiscoveryDocumentResponse> RequestDiscoveryDocument ();
|
Task<DiscoveryDocumentResponse> RequestDiscoveryDocument();
|
||||||
Task<XTokenResponse> RequestScopeAccessToken (string scope);
|
Task<XTokenResponse> RequestScopeAccessToken(string scope);
|
||||||
Task<TokenIntrospectionResponse> Introspection (XTokenResponse model);
|
Task<TokenIntrospectionResponse> Introspection(XTokenResponse model);
|
||||||
Task<XLoginResponse> Login (XLoginRequest model);
|
Task<XLoginResponse> Login(XLoginRequest model);
|
||||||
Task Logout (XTokenResponse model);
|
Task Logout(XTokenResponse model);
|
||||||
Task<XTokenResponse> Authenticate (XLoginRequest model);
|
Task<XTokenResponse> Authenticate(XLoginRequest model);
|
||||||
Task<XTokenResponse> RefreshTokens (XTokenResponse model);
|
Task<XTokenResponse> RefreshTokens(XTokenResponse model);
|
||||||
|
|
||||||
Task ChangePassword (
|
Task ChangePassword(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
XActionRequest model
|
XActionRequest model
|
||||||
);
|
);
|
||||||
@@ -53,67 +56,67 @@ namespace xIdentityService.Interfaces {
|
|||||||
|
|
||||||
//
|
//
|
||||||
#region Profile ...
|
#region Profile ...
|
||||||
Task<IEnumerable<string>> GetUserNames (
|
Task<IEnumerable<string>> GetUserNames(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string userIds
|
string userIds
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<IEnumerable<XUserNameIdResponse>> GetUserNameIds (
|
Task<IEnumerable<XUserNameIdResponse>> GetUserNameIds(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
XUserNameIdRequest model
|
XUserNameIdRequest model
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XUserProfileDto> GetUserProfile (
|
Task<XUserProfileDto> GetUserProfile(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string userSelectByParam
|
string userSelectByParam
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XQueryResult<XUserProfileDto>> QueryUsers (
|
Task<XQueryResult<XUserProfileDto>> QueryUsers(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
XQuery query
|
XQuery query
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XQueryResult<XUserProfileDto>> QueryInRoleUsers (
|
Task<XQueryResult<XUserProfileDto>> QueryInRoleUsers(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string role,
|
string role,
|
||||||
XQuery query,
|
XQuery query,
|
||||||
bool forceRole = false
|
bool forceRole = false
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XQueryResult<XProfileImage>> QueryAvatars (
|
Task<XQueryResult<XProfileImage>> QueryAvatars(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string userSelectByParam,
|
string userSelectByParam,
|
||||||
XQuery query
|
XQuery query
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XUserProfileDto> ProfileUpdateAsync (
|
Task<XUserProfileDto> ProfileUpdateAsync(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string userSelectByParam,
|
string userSelectByParam,
|
||||||
XProfileUpdateRequest model
|
XProfileUpdateRequest model
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XUserProfileDto> FullProfileUpdateAsync (
|
Task<XUserProfileDto> FullProfileUpdateAsync(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string userSelectByParam,
|
string userSelectByParam,
|
||||||
XProfileUpdateRequest request
|
XProfileUpdateRequest request
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XUserProfileDto> AddAvatar (
|
Task<XUserProfileDto> AddAvatar(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
IFormFile file
|
IFormFile file
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XUserProfileDto> AddAvatars (
|
Task<XUserProfileDto> AddAvatars(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
IFormFileCollection files
|
IFormFileCollection files
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XUserProfileDto> SetAvatar (
|
Task<XUserProfileDto> SetAvatar(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
int avatarId
|
int avatarId
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XUserProfileDto> RemoveAvatars (
|
Task<XUserProfileDto> RemoveAvatars(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string avatarIds
|
string avatarIds
|
||||||
);
|
);
|
||||||
@@ -121,142 +124,142 @@ namespace xIdentityService.Interfaces {
|
|||||||
|
|
||||||
//
|
//
|
||||||
#region Registration ...
|
#region Registration ...
|
||||||
Task<bool> CanRegister (string userSelectByParam);
|
Task<bool> CanRegister(string userSelectByParam);
|
||||||
|
|
||||||
Task<XActionResponse> InviteUser (
|
Task<XActionResponse> InviteUser(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
XActionRequest model
|
XActionRequest model
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XActionResponse> RequestRegistration (
|
Task<XActionResponse> RequestRegistration(
|
||||||
XActionRequest model
|
XActionRequest model
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XActionResponse> AddAccountInfo (
|
Task<XActionResponse> AddAccountInfo(
|
||||||
XActionRequest model
|
XActionRequest model
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XActionResponse> AttachProfileImage (
|
Task<XActionResponse> AttachProfileImage(
|
||||||
string actionToken,
|
string actionToken,
|
||||||
IFormFile file
|
IFormFile file
|
||||||
);
|
);
|
||||||
|
|
||||||
Task FinishRegistration (XActionRequest model);
|
Task FinishRegistration(XActionRequest model);
|
||||||
|
|
||||||
Task<bool> IsConfirmedEmail (
|
Task<bool> IsConfirmedEmail(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string userSelectByParam
|
string userSelectByParam
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<bool> IsConfirmedMobile (
|
Task<bool> IsConfirmedMobile(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string userSelectByParam
|
string userSelectByParam
|
||||||
);
|
);
|
||||||
|
|
||||||
Task RequestConfirmRegistration (XActionRequest model);
|
Task RequestConfirmRegistration(XActionRequest model);
|
||||||
|
|
||||||
Task ConfirmRegistration (
|
Task ConfirmRegistration(
|
||||||
XActionRequest model
|
XActionRequest model
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XActionResponse> RequestConfirmMobile (XActionRequest model);
|
Task<XActionResponse> RequestConfirmMobile(XActionRequest model);
|
||||||
|
|
||||||
Task<XActionResponse> ConfirmMobileNumber (XActionRequest model);
|
Task<XActionResponse> ConfirmMobileNumber(XActionRequest model);
|
||||||
|
|
||||||
Task<XActionResponse> RequestConfirmEmail (XActionRequest model);
|
Task<XActionResponse> RequestConfirmEmail(XActionRequest model);
|
||||||
|
|
||||||
Task<XActionResponse> ConfirmEmailAddress (XActionRequest model);
|
Task<XActionResponse> ConfirmEmailAddress(XActionRequest model);
|
||||||
|
|
||||||
Task<XActionResponse> RequestResetPassword (XActionRequest model);
|
Task<XActionResponse> RequestResetPassword(XActionRequest model);
|
||||||
|
|
||||||
Task ResetPassword (XActionRequest model);
|
Task ResetPassword(XActionRequest model);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Friendship ...
|
#region Friendship ...
|
||||||
Task<XFriendshipFollowing> Follow (
|
Task<XFriendshipFollowing> Follow(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<bool> Cancel (
|
Task<bool> Cancel(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task UnFollowFollower (
|
Task UnFollowFollower(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task UnFollowFollowing (
|
Task UnFollowFollowing(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XFriendshipFollowing> Block (
|
Task<XFriendshipFollowing> Block(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XFriendshipFollowing> UnBlock (
|
Task<XFriendshipFollowing> UnBlock(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XFriendshipFollower> AcceptRequest (
|
Task<XFriendshipFollower> AcceptRequest(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XFriendshipFollower> RejectRequest (
|
Task<XFriendshipFollower> RejectRequest(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<bool> IsFollower (
|
Task<bool> IsFollower(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XFriendshipFollower> GetFollower (
|
Task<XFriendshipFollower> GetFollower(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XFriendshipState> GetFollowerState (
|
Task<XFriendshipState> GetFollowerState(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<IEnumerable<XFriendshipFollower>> GetFollowers (XTokenResponse tokens);
|
Task<IEnumerable<XFriendshipFollower>> GetFollowers(XTokenResponse tokens);
|
||||||
|
|
||||||
Task<IEnumerable<XFriendshipFollower>> GetAllFollowers (XTokenResponse tokens);
|
Task<IEnumerable<XFriendshipFollower>> GetAllFollowers(XTokenResponse tokens);
|
||||||
|
|
||||||
Task<bool> IsFollowing (
|
Task<bool> IsFollowing(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XFriendshipFollowing> GetFollowing (
|
Task<XFriendshipFollowing> GetFollowing(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<XFriendshipState> GetFollowingState (
|
Task<XFriendshipState> GetFollowingState(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<IEnumerable<XFriendshipFollowing>> GetFollowings (XTokenResponse tokens);
|
Task<IEnumerable<XFriendshipFollowing>> GetFollowings(XTokenResponse tokens);
|
||||||
|
|
||||||
Task<IEnumerable<XFriendshipFollowing>> GetAllFollowings (XTokenResponse tokens);
|
Task<IEnumerable<XFriendshipFollowing>> GetAllFollowings(XTokenResponse tokens);
|
||||||
|
|
||||||
Task<IEnumerable<string>> GetFollowingList (XTokenResponse tokens);
|
Task<IEnumerable<string>> GetFollowingList(XTokenResponse tokens);
|
||||||
|
|
||||||
Task<IEnumerable<string>> GetFollowersList (XTokenResponse tokens);
|
Task<IEnumerable<string>> GetFollowersList(XTokenResponse tokens);
|
||||||
|
|
||||||
Task<XFriendshipInfoDto> GetFriendshipInfo (
|
Task<XFriendshipInfoDto> GetFriendshipInfo(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string destUser
|
string destUser
|
||||||
);
|
);
|
||||||
@@ -264,20 +267,33 @@ namespace xIdentityService.Interfaces {
|
|||||||
|
|
||||||
//
|
//
|
||||||
#region Admin ...
|
#region Admin ...
|
||||||
Task<IEnumerable<string>> Ban (
|
Task<IEnumerable<string>> Ban(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
XUserNameIdRequest model
|
XUserNameIdRequest model
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<IEnumerable<string>> UnBan (
|
Task<IEnumerable<string>> UnBan(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
XUserNameIdRequest model
|
XUserNameIdRequest model
|
||||||
);
|
);
|
||||||
|
|
||||||
Task<bool> IsBanned (
|
Task<bool> IsBanned(
|
||||||
XTokenResponse tokens,
|
XTokenResponse tokens,
|
||||||
string userSelectByParam
|
string userSelectByParam
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Open Actions ...
|
||||||
|
Task<XOpenActionUserInfoDto> GetUserInfo(
|
||||||
|
XDeviceDto device,
|
||||||
|
string userSelectByParam
|
||||||
|
);
|
||||||
|
Task<XOpenActionUserInfoDto> GetUserInfo(XOpenActionInnerDto dto);
|
||||||
|
Task<XOpenActionUserInfoDto> GetUserInfo(
|
||||||
|
string token,
|
||||||
|
string request
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using RestSharp;
|
||||||
|
|
||||||
|
namespace xIdentityService.Models
|
||||||
|
{
|
||||||
|
public class XBaseRestResponse<T>
|
||||||
|
{
|
||||||
|
public T Model { get; set; }
|
||||||
|
public IRestResponse Response { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using xCommons.Constants;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using xExceptions.Constants;
|
||||||
|
using xHttpService.Constants;
|
||||||
|
using xIdentityModels.Dtos;
|
||||||
|
using xIdentityService.Constants;
|
||||||
|
using xModels.Dtos;
|
||||||
|
using xModels.Extensions;
|
||||||
|
|
||||||
|
namespace xIdentityService.Providers
|
||||||
|
{
|
||||||
|
public partial class XIdentityProvider
|
||||||
|
{
|
||||||
|
public async Task<XOpenActionUserInfoDto> GetUserInfo(
|
||||||
|
XDeviceDto device,
|
||||||
|
string userSelectByParam
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
validationProvider.NotNull(device);
|
||||||
|
validationProvider.NotEmpty(userSelectByParam);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Open Action Model ...
|
||||||
|
var opaModel = new XOpenActionRequestDto
|
||||||
|
{
|
||||||
|
Device = device,
|
||||||
|
Payload = userSelectByParam,
|
||||||
|
Action = XOpenActions.GetUserInfo,
|
||||||
|
Timestamp = DateTime.UtcNow.AddMinutes(5)
|
||||||
|
};
|
||||||
|
if (!opaModel.Validate())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fill Checksum Filed ...
|
||||||
|
var token = opaModel.ToOpenActionToken();
|
||||||
|
opaModel.Checksum = token;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Request ...
|
||||||
|
var opaJson = opaModel.ToJson();
|
||||||
|
var requestString = SecurityProvider.Encrypt(opaJson);
|
||||||
|
|
||||||
|
//
|
||||||
|
return await GetUserInfo(
|
||||||
|
token: token,
|
||||||
|
request: requestString
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<XOpenActionUserInfoDto> GetUserInfo(XOpenActionInnerDto dto)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return await GetUserInfo(
|
||||||
|
token: dto.Token,
|
||||||
|
request: dto.Payload
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<XOpenActionUserInfoDto> GetUserInfo(
|
||||||
|
string token,
|
||||||
|
string request
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
validationProvider.NotEmpty(token);
|
||||||
|
validationProvider.NotEmpty(request);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Rest Client ...
|
||||||
|
var client = GetRestClient();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Rest Request ...
|
||||||
|
var requestU = GetRestRequet(
|
||||||
|
XApiAccountEndpoint.GetUserInfo,
|
||||||
|
@params: new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ XParam.XRequest.GetStringValue(), request }
|
||||||
|
},
|
||||||
|
headers: new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ XAuthentication.TOKEN, token}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
var response = await RunRestRequestByResponse<string>(
|
||||||
|
client,
|
||||||
|
requestU,
|
||||||
|
XHttpMethod.GET
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now we Have to Validate the recieved response ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read token from Headers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
var responseToken = response.Response.Headers.First(h => h.Name == XAuthentication.TOKEN).ToString();
|
||||||
|
if (responseToken.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
XException.ActionFailed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var responseJson = SecurityProvider.Decrypt(response.Model);
|
||||||
|
if (responseJson.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
XException.ActionFailed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Model and Validate it ...
|
||||||
|
var responseModel = responseJson.FromJSON<XOpenActionRequestDto>();
|
||||||
|
if (responseModel.IsNull() ||
|
||||||
|
responseModel.Timestamp.IsExPired() ||
|
||||||
|
responseModel.Payload.IsNullOrEmpty() ||
|
||||||
|
// !responseModel.Device.IsSameAs(device) ||
|
||||||
|
responseToken != responseModel.Checksum)
|
||||||
|
{
|
||||||
|
XException.ActionFailed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try to Retrieve Model ...
|
||||||
|
var result = responseModel.Payload.FromJSON<XOpenActionUserInfoDto>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ using xIdentityModels.Models;
|
|||||||
using xIdentityService.Configuration;
|
using xIdentityService.Configuration;
|
||||||
using xIdentityService.Constants;
|
using xIdentityService.Constants;
|
||||||
using xIdentityService.Interfaces;
|
using xIdentityService.Interfaces;
|
||||||
|
using xIdentityService.Models;
|
||||||
|
|
||||||
namespace xIdentityService.Providers {
|
namespace xIdentityService.Providers {
|
||||||
public partial class XIdentityProvider : IXIdentityProvider {
|
public partial class XIdentityProvider : IXIdentityProvider {
|
||||||
@@ -30,16 +31,18 @@ namespace xIdentityService.Providers {
|
|||||||
private readonly XValidationProvider validationProvider;
|
private readonly XValidationProvider validationProvider;
|
||||||
private readonly XIdentityServiceConfiguration identityConfiguration;
|
private readonly XIdentityServiceConfiguration identityConfiguration;
|
||||||
|
|
||||||
|
public ILogger<XIdentityProvider> Logger { get; }
|
||||||
|
public IXSecurityProvider SecurityProvider { get; }
|
||||||
|
|
||||||
public string BaseUrl { get; }
|
public string BaseUrl { get; }
|
||||||
public string RevisionSecretKey { get; }
|
public string RevisionSecretKey { get; }
|
||||||
|
|
||||||
public bool ReadResponseAsString { get; set; }
|
public bool ReadResponseAsString { get; set; }
|
||||||
public ILogger<XIdentityProvider> Logger { get; }
|
|
||||||
|
|
||||||
public XIdentityProvider (
|
public XIdentityProvider (
|
||||||
IXTokenProvider tokenProvider,
|
IXTokenProvider tokenProvider,
|
||||||
IHostingEnvironment environment,
|
IHostingEnvironment environment,
|
||||||
ILogger<XIdentityProvider> logger,
|
ILogger<XIdentityProvider> logger,
|
||||||
|
IXSecurityProvider securityProvider,
|
||||||
XIdentityServiceConfiguration identityConfiguration,
|
XIdentityServiceConfiguration identityConfiguration,
|
||||||
XValidationProvider validationProvider
|
XValidationProvider validationProvider
|
||||||
) {
|
) {
|
||||||
@@ -50,6 +53,7 @@ namespace xIdentityService.Providers {
|
|||||||
//
|
//
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
Logger = logger;
|
Logger = logger;
|
||||||
|
SecurityProvider = securityProvider;
|
||||||
|
|
||||||
//
|
//
|
||||||
this.identityConfiguration = identityConfiguration;
|
this.identityConfiguration = identityConfiguration;
|
||||||
@@ -345,6 +349,149 @@ namespace xIdentityService.Providers {
|
|||||||
//
|
//
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
public async Task<XBaseRestResponse<T>> RunRestRequestByResponse<T> (
|
||||||
|
RestClient client,
|
||||||
|
RestRequest request,
|
||||||
|
XHttpMethod method,
|
||||||
|
bool supportRefreshingTokens = true
|
||||||
|
) {
|
||||||
|
//
|
||||||
|
var response = await Task.Run (async () => {
|
||||||
|
//
|
||||||
|
IRestResponse resp = null;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Call Endpoint Service using Specified Method ...
|
||||||
|
switch (method) {
|
||||||
|
//
|
||||||
|
// Get ...
|
||||||
|
case XHttpMethod.GET:
|
||||||
|
resp = client.Get (request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Put ...
|
||||||
|
case XHttpMethod.PUT:
|
||||||
|
resp = client.Put (request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Post ...
|
||||||
|
case XHttpMethod.POST:
|
||||||
|
resp = client.Post (request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Delete ...
|
||||||
|
case XHttpMethod.DELETE:
|
||||||
|
resp = client.Delete (request);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!resp.IsSuccessful) {
|
||||||
|
//
|
||||||
|
// Log Exception ...
|
||||||
|
Logger.LogError ($"Error: {resp.ErrorMessage}");
|
||||||
|
Logger.LogError ($"Exception: {resp.ErrorException.ToJSON()}");
|
||||||
|
if (!resp.ErrorMessage.IsNullOrEmpty () &&
|
||||||
|
resp.ErrorMessage.Contains ("timed out")) {
|
||||||
|
XException.Timeout.Throw ();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Check UnAuthorized Status here for
|
||||||
|
// Refresh Tokens or Issue Correct Exception ...
|
||||||
|
if (supportRefreshingTokens &&
|
||||||
|
resp.StatusCode == System.Net.HttpStatusCode.Unauthorized) {
|
||||||
|
//
|
||||||
|
var isRefreshed = request.Parameters.Any (rp =>
|
||||||
|
rp.Name == XParam.XIsRefreshed.GetStringValue () &&
|
||||||
|
rp.Value.ToString ().ToNormalString () == true.ToJSON ());
|
||||||
|
|
||||||
|
//
|
||||||
|
Logger.LogInformation ($"isRefreshed: {isRefreshed}");
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get Access Token ...
|
||||||
|
XTokenResponse tokens = null;
|
||||||
|
var accessToken = request.Parameters.FirstOrDefault (rp =>
|
||||||
|
rp.Name.ToNormalString () == XAuthorization.Header.ToNormalString ()).Value.ToString ();
|
||||||
|
if (!accessToken.IsNullOrEmpty ()) {
|
||||||
|
//
|
||||||
|
accessToken = accessToken.Replace (XAuthorization.TokenIdentifier, "");
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!accessToken.IsNullOrEmpty ()) {
|
||||||
|
tokens = await tokenProvider.RetrieveToken (accessToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Refresh Token and then re do request ...
|
||||||
|
if (!isRefreshed &&
|
||||||
|
!accessToken.IsNullOrEmpty () &&
|
||||||
|
!tokens.IsNull () &&
|
||||||
|
tokens.IsRefreshable ()) {
|
||||||
|
//
|
||||||
|
request.AddHeader (XParam.XIsRefreshed.GetStringValue (), true.ToJSON ());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Refreshe Tokens ...
|
||||||
|
var refreshedTokens = await RefreshTokens (tokens);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Renew Rest Client with Refreshed Tokens ...
|
||||||
|
var timeout = client.Timeout;
|
||||||
|
client = GetRestClient (refreshedTokens);
|
||||||
|
client.Timeout = Timeout.Infinite;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Request Again using renew Client ...
|
||||||
|
return await RunRestRequestByResponse<T> (
|
||||||
|
client: client,
|
||||||
|
request: request,
|
||||||
|
method: method
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var ex = resp.Content.ToXError ();
|
||||||
|
if (!ex.IsNull ()) {
|
||||||
|
throw ex.ToException ();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// UnAuthorized ...
|
||||||
|
if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized) {
|
||||||
|
XException.NotAuthorized.Throw ();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// NotFound ...
|
||||||
|
if (resp.StatusCode == System.Net.HttpStatusCode.NotFound) {
|
||||||
|
XException.NotFound.Throw ();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XException.ActionFailed.Throw ();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = new XBaseRestResponse<T>
|
||||||
|
{
|
||||||
|
Response = resp,
|
||||||
|
Model = resp.Content.FromJSON<T> ()
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get User SelectBy Param
|
/// Get User SelectBy Param
|
||||||
|
|||||||
Reference in New Issue
Block a user