mirror of
https://github.com/bitwarden/server.git
synced 2025-04-23 22:15:10 -05:00

* Get limited life attachment download URL This change limits url download to a 1min lifetime. This requires moving to a new container to allow for non-public blob access. Clients will have to call GetAttachmentData api function to receive the download URL. For backwards compatibility, attachment URLs are still present, but will not work for attachments stored in non-public access blobs. * Make GlobalSettings interface for testing * Test LocalAttachmentStorageService equivalence * Remove comment * Add missing globalSettings using * Simplify default attachment container * Default to attachments containe for existing methods A new upload method will be made for uploading to attachments-v2. For compatibility for clients which don't use these new methods, we need to still use the old container. The new container will be used only for new uploads * Remove Default MetaData fixture. * Keep attachments container blob-level security for all instances * Close unclosed FileStream * Favor default value for noop services
81 lines
3.1 KiB
C#
81 lines
3.1 KiB
C#
using IdentityServer4.Models;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Bit.Core.Settings;
|
|
|
|
namespace Bit.Core.IdentityServer
|
|
{
|
|
public class ApiClient : Client
|
|
{
|
|
public ApiClient(
|
|
GlobalSettings globalSettings,
|
|
string id,
|
|
int refreshTokenSlidingDays,
|
|
int accessTokenLifetimeHours,
|
|
string[] scopes = null)
|
|
{
|
|
ClientId = id;
|
|
AllowedGrantTypes = new[] { GrantType.ResourceOwnerPassword, GrantType.AuthorizationCode };
|
|
RefreshTokenExpiration = TokenExpiration.Sliding;
|
|
RefreshTokenUsage = TokenUsage.ReUse;
|
|
SlidingRefreshTokenLifetime = 86400 * refreshTokenSlidingDays;
|
|
AbsoluteRefreshTokenLifetime = 0; // forever
|
|
UpdateAccessTokenClaimsOnRefresh = true;
|
|
AccessTokenLifetime = 3600 * accessTokenLifetimeHours;
|
|
AllowOfflineAccess = true;
|
|
|
|
RequireConsent = false;
|
|
RequirePkce = true;
|
|
RequireClientSecret = false;
|
|
if (id == "web")
|
|
{
|
|
RedirectUris = new[] { $"{globalSettings.BaseServiceUri.Vault}/sso-connector.html" };
|
|
PostLogoutRedirectUris = new[] { globalSettings.BaseServiceUri.Vault };
|
|
AllowedCorsOrigins = new[] { globalSettings.BaseServiceUri.Vault };
|
|
}
|
|
else if (id == "desktop")
|
|
{
|
|
RedirectUris = new[] { "bitwarden://sso-callback" };
|
|
PostLogoutRedirectUris = new[] { "bitwarden://logged-out" };
|
|
}
|
|
else if (id == "connector")
|
|
{
|
|
var connectorUris = new List<string>();
|
|
for (var port = 8065; port <= 8070; port++)
|
|
{
|
|
connectorUris.Add(string.Format("http://localhost:{0}", port));
|
|
}
|
|
RedirectUris = connectorUris.Append("bwdc://sso-callback").ToList();
|
|
PostLogoutRedirectUris = connectorUris.Append("bwdc://logged-out").ToList();
|
|
}
|
|
else if (id == "browser")
|
|
{
|
|
RedirectUris = new[] { $"{globalSettings.BaseServiceUri.Vault}/sso-connector.html" };
|
|
PostLogoutRedirectUris = new[] { globalSettings.BaseServiceUri.Vault };
|
|
AllowedCorsOrigins = new[] { globalSettings.BaseServiceUri.Vault };
|
|
}
|
|
else if (id == "cli")
|
|
{
|
|
var cliUris = new List<string>();
|
|
for (var port = 8065; port <= 8070; port++)
|
|
{
|
|
cliUris.Add(string.Format("http://localhost:{0}", port));
|
|
}
|
|
RedirectUris = cliUris;
|
|
PostLogoutRedirectUris = cliUris;
|
|
}
|
|
else if (id == "mobile")
|
|
{
|
|
RedirectUris = new[] { "bitwarden://sso-callback" };
|
|
PostLogoutRedirectUris = new[] { "bitwarden://logged-out" };
|
|
}
|
|
|
|
if (scopes == null)
|
|
{
|
|
scopes = new string[] { "api" };
|
|
}
|
|
AllowedScopes = scopes;
|
|
}
|
|
}
|
|
}
|