last ...
This commit is contained in:
@@ -17,6 +17,67 @@ namespace xIds.Providers
|
||||
{
|
||||
//
|
||||
#region Custom Actions ...
|
||||
/// <summary>
|
||||
/// Show Specifid Api Key ...
|
||||
/// </summary>
|
||||
/// <param name="apiKeyId"></param>
|
||||
/// <param name="applicationId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> ShowApiKey(
|
||||
Guid apiKeyId,
|
||||
int applicationId,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (
|
||||
apiKeyId.IsDefaultGuid() ||
|
||||
userInfo.IsNullOrDefault() ||
|
||||
!applicationId.IsValidIntId()
|
||||
)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Application Exists ...
|
||||
var application = await GetApplicationAsync(
|
||||
id: applicationId,
|
||||
userInfo: userInfo,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (application.IsNullOrDefault())
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Owner ...
|
||||
if (!IsOwned(application, userInfo))
|
||||
{
|
||||
XException.NotAllowed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve ApiKey Entity ...
|
||||
// Since ApiKey is Only Exists on ApiKey Entity ...
|
||||
var entity = await dbContext.ApiKeys
|
||||
.FirstOrDefaultAsync(x => x.Id == apiKeyId);
|
||||
if (entity.IsNullOrDefault())
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
return entity.Key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a New ApiKey and Add It to DB ...
|
||||
/// </summary>
|
||||
@@ -114,6 +175,7 @@ namespace xIds.Providers
|
||||
// Add Item to Database ...
|
||||
result = await AddApiKeyAsync(
|
||||
item: result,
|
||||
apiKey: plainKey,
|
||||
userInfo: userInfo,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
@@ -371,8 +433,8 @@ namespace xIds.Providers
|
||||
.ParseListString<string>();
|
||||
var allowedScopes = (keyModel.AllowedScopes ?? string.Empty)
|
||||
.FromJSON<IEnumerable<string>>();
|
||||
result.Scopes = [..allowedScopes];
|
||||
|
||||
result.Scopes = [.. allowedScopes];
|
||||
|
||||
//
|
||||
// Check Application is Exists and Active ...
|
||||
var application = await dbContext.Applications
|
||||
|
||||
Reference in New Issue
Block a user