using System.Security.Claims;
using Bit.Core.AdminConsole.Context;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Auth.Identity;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Core.Settings;
using Microsoft.AspNetCore.Http;
namespace Bit.Core.Context;
///
/// Provides information about the current HTTP request and the currently authenticated user (if any).
/// This is often (but not exclusively) parsed from the JWT in the current request.
///
///
/// This interface suffers from having too much responsibility; consider whether any new code can go in a more
/// specific class rather than adding it here.
///
public interface ICurrentContext
{
HttpContext HttpContext { get; set; }
Guid? UserId { get; set; }
User User { get; set; }
string DeviceIdentifier { get; set; }
DeviceType? DeviceType { get; set; }
string IpAddress { get; set; }
string CountryName { get; set; }
List Organizations { get; set; }
Guid? InstallationId { get; set; }
Guid? OrganizationId { get; set; }
IdentityClientType IdentityClientType { get; set; }
string ClientId { get; set; }
Version ClientVersion { get; set; }
bool ClientVersionIsPrerelease { get; set; }
Task BuildAsync(HttpContext httpContext, GlobalSettings globalSettings);
Task BuildAsync(ClaimsPrincipal user, GlobalSettings globalSettings);
Task SetContextAsync(ClaimsPrincipal user);
Task OrganizationUser(Guid orgId);
Task OrganizationAdmin(Guid orgId);
Task OrganizationOwner(Guid orgId);
Task OrganizationCustom(Guid orgId);
Task AccessEventLogs(Guid orgId);
Task AccessImportExport(Guid orgId);
Task AccessReports(Guid orgId);
[Obsolete("Deprecated. Use an authorization handler checking the specific permissions required instead.")]
Task EditAnyCollection(Guid orgId);
[Obsolete("Deprecated. Use an authorization handler checking the specific permissions required instead.")]
Task ViewAllCollections(Guid orgId);
Task ManageGroups(Guid orgId);
Task ManagePolicies(Guid orgId);
Task ManageSso(Guid orgId);
Task ManageUsers(Guid orgId);
Task AccessMembersTab(Guid orgId);
Task ManageScim(Guid orgId);
Task ManageResetPassword(Guid orgId);
Task ViewSubscription(Guid orgId);
Task EditSubscription(Guid orgId);
Task EditPaymentMethods(Guid orgId);
Task ViewBillingHistory(Guid orgId);
///
/// Returns true if the current user is a member of a provider that manages the specified organization.
/// This generally gives the user administrative privileges for the organization.
///
///
///
Task ProviderUserForOrgAsync(Guid orgId);
///
/// Returns true if the current user is a Provider Admin of the specified provider.
///
bool ProviderProviderAdmin(Guid providerId);
///
/// Returns true if the current user is a member of the specified provider (with any role).
///
bool ProviderUser(Guid providerId);
bool ProviderManageUsers(Guid providerId);
bool ProviderAccessEventLogs(Guid providerId);
bool AccessProviderOrganizations(Guid providerId);
bool ManageProviderOrganizations(Guid providerId);
Task> OrganizationMembershipAsync(
IOrganizationUserRepository organizationUserRepository, Guid userId);
Task> ProviderMembershipAsync(
IProviderUserRepository providerUserRepository, Guid userId);
Task ProviderIdForOrg(Guid orgId);
bool AccessSecretsManager(Guid organizationId);
CurrentContextOrganization? GetOrganization(Guid orgId);
}