1
0
mirror of https://github.com/bitwarden/server synced 2025-12-18 09:13:19 +00:00

added installations, push scoped tokens, push api

This commit is contained in:
Kyle Spearrin
2017-08-10 14:39:11 -04:00
parent 6ff9aeac97
commit e538817eb6
17 changed files with 234 additions and 14 deletions

View File

@@ -0,0 +1,48 @@
using IdentityServer4.Models;
using System.Collections.Generic;
using System.Linq;
namespace Bit.Core.IdentityServer
{
public class StaticClients
{
public static IDictionary<string, Client> GetApiClients()
{
return new List<Client>
{
new ApiClient("mobile", 90, 1),
new ApiClient("web", 1, 1),
new ApiClient("browser", 30, 1),
new ApiClient("desktop", 30, 1),
new ApiClient("connector", 30, 24)
}.ToDictionary(c => c.ClientId);
}
public class ApiClient : Client
{
public ApiClient(
string id,
int refreshTokenSlidingDays,
int accessTokenLifetimeHours,
string[] scopes = null)
{
ClientId = id;
RequireClientSecret = false;
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword;
RefreshTokenExpiration = TokenExpiration.Sliding;
RefreshTokenUsage = TokenUsage.ReUse;
SlidingRefreshTokenLifetime = 86400 * refreshTokenSlidingDays;
AbsoluteRefreshTokenLifetime = int.MaxValue; // forever
UpdateAccessTokenClaimsOnRefresh = true;
AccessTokenLifetime = 3600 * accessTokenLifetimeHours;
AllowOfflineAccess = true;
if(scopes == null)
{
scopes = new string[] { "api" };
}
AllowedScopes = scopes;
}
}
}
}