Add API Keys Application identifier

This lets the authorize api key screen redirect to the defined url  and provide it with the user id, permissions granted and the key.

This also allows apps to match existing api keys generated for it specifically using the application identifier, and if matched, presented with a confirmation page before redirection.
This commit is contained in:
Kukks
2020-02-28 19:42:17 +01:00
parent cf7c5102fc
commit 7ca74aeea7
5 changed files with 118 additions and 9 deletions

View File

@@ -30,9 +30,18 @@ namespace BTCPayServer.Security.GreenField
using (var context = _applicationDbContextFactory.CreateContext())
{
var queryable = context.ApiKeys.AsQueryable();
if (query?.UserId != null && query.UserId.Any())
if (query != null)
{
queryable = queryable.Where(data => query.UserId.Contains(data.UserId));
if (query.UserId != null && query.UserId.Any())
{
queryable = queryable.Where(data => query.UserId.Contains(data.UserId));
}
if (query.ApplicationIdentifier != null && query.ApplicationIdentifier.Any())
{
queryable = queryable.Where(data =>
query.ApplicationIdentifier.Contains(data.ApplicationIdentifier));
}
}
return await queryable.ToListAsync();