1
0
mirror of https://github.com/bitwarden/server synced 2025-12-25 04:33:26 +00:00
Files
server/src/Core/IdentityServer/StaticClients.cs
2017-08-10 14:39:11 -04:00

49 lines
1.6 KiB
C#

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;
}
}
}
}