mirror of
https://github.com/bitwarden/server.git
synced 2025-05-05 19:52:20 -05:00
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using IdentityServer4.Models;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Bit.Core.IdentityServer
|
|
{
|
|
public class Clients
|
|
{
|
|
public static IEnumerable<Client> GetClients()
|
|
{
|
|
return new List<Client>
|
|
{
|
|
new ApiClient("mobile", 90, 1),
|
|
new ApiClient("web", 1, 1),
|
|
new ApiClient("browser", 30, 1),
|
|
new ApiClient("desktop", 30, 1)
|
|
};
|
|
}
|
|
|
|
public class ApiClient : Client
|
|
{
|
|
public ApiClient(
|
|
string id,
|
|
int refreshTokenSlidingDays,
|
|
int accessTokenLifetimeHours,
|
|
string[] additionalScopes = 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;
|
|
|
|
var scopes = new List<string> { "api" };
|
|
if(additionalScopes != null)
|
|
{
|
|
scopes.AddRange(additionalScopes);
|
|
}
|
|
AllowedScopes = scopes;
|
|
}
|
|
}
|
|
}
|
|
}
|