public ClaimsBenchmarksBase() { IConfigurationBuilder configurationBuilder = new ConfigurationBuilder() .AddEnvironmentVariables() .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true); IConfiguration configuration = configurationBuilder.Build(); this.ClientTenantId = configuration["ClientTenantId"]; this.AdministratorPrincipalObjectId = configuration["AdministratorPrincipalObjectId"]; ServiceProvider serviceProvider = new ServiceCollection() .AddClaimsClient(sp => configuration.GetSection("ClaimsClient").Get <ClaimsClientOptions>()) .AddSingleton(sp => configuration.GetSection("TenancyClient").Get <TenancyClientOptions>()) .AddTenancyClient(enableResponseCaching: true) .AddJsonNetPropertyBag() .AddBlobContainerV2ToV3Transition() .AddAzureBlobStorageClientSourceFromDynamicConfiguration() .AddServiceIdentityAzureTokenCredentialSourceFromLegacyConnectionString(configuration["AzureServicesAuthConnectionString"]) .AddMicrosoftRestAdapterForServiceIdentityAccessTokenSource() .BuildServiceProvider(); this.ClaimsService = serviceProvider.GetRequiredService <IClaimsService>(); this.TenancyService = serviceProvider.GetRequiredService <ITenancyService>(); this.TenantBlobContainerClientFactory = serviceProvider.GetRequiredService <IBlobContainerSourceWithTenantLegacyTransition>(); this.PropertyBagFactory = serviceProvider.GetRequiredService <IPropertyBagFactory>(); }
/// <summary> /// Gets permission results for a set of target resources and access types /// </summary> /// <remarks> /// Gets permission results for a set of target resources and access types /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='tenantId'> /// The tenant within which the request should operate /// </param> /// <param name='body'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> GetClaimPermissionsPermissionBatchAsync(this IClaimsService operations, string tenantId, IList <ClaimPermissionsBatchRequestItem> body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetClaimPermissionsPermissionBatchWithHttpMessagesAsync(tenantId, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create a Claim Permissions /// </summary> /// <remarks> /// Creates a permissions definition for a claim /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='tenantId'> /// The tenant within which the request should operate /// </param> /// <param name='body'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> CreateClaimPermissionsAsync(this IClaimsService operations, string tenantId, CreateClaimPermissionsRequest body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateClaimPermissionsWithHttpMessagesAsync(tenantId, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create a resource access rule set /// </summary> /// <remarks> /// Creates a resource access rule set /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='tenantId'> /// The tenant within which the request should operate /// </param> /// <param name='body'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> CreateResourceAccessRuleSetAsync(this IClaimsService operations, string tenantId, ResourceAccessRuleSet body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateResourceAccessRuleSetWithHttpMessagesAsync(tenantId, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// View swagger definition for this API /// </summary> /// <remarks> /// View swagger definition for this API /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> GetSwaggerAsync(this IClaimsService operations, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetSwaggerWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Set up the initial administrator permissions for a tenant /// </summary> /// <remarks> /// Creates a resource access rule set providing access to all endpoints and a /// Claim Permission granting that access to the specified role /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='tenantId'> /// The tenant within which the request should operate /// </param> /// <param name='body'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ProblemDetails> InitializeTenantAsync(this IClaimsService operations, string tenantId, Body body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.InitializeTenantWithHttpMessagesAsync(tenantId, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public RecipeService( IClaimsService claimsService, IAppDbContext appDbContext) { _claimsService = claimsService; _appDbContext = appDbContext; }
public SuperAdminHandler( IServiceProvider serviceProvider, IClaimsService claimsService) { _serviceProvider = serviceProvider; _claimsService = claimsService; }
public WorkOrderService(WorkOrderContext context, IMapper mapper, IClaimsService claimsService, IPhotoService photoService) { _context = context; _mapper = mapper; _claimsService = claimsService; _photoService = photoService; }
public OrganizatorController(IOrganizatorRepository organizatorRepository, IUserRepository userRepository, IOrganizatorService organizatorService, IClaimsService claimsService) { _organizatorRepository = organizatorRepository; _userRepository = userRepository; _organizatorService = organizatorService; _claimsService = claimsService; }
public ClientTestableClaimsService( ClaimsServiceTestTenants testTenants, string serviceUrl, JsonSerializerSettings serializerSettings) { this.testTenants = testTenants; this.serializerSettings = serializerSettings; // When testing the Functions Host locally (and also when doing in-process testing that // emulates functions hosting) we can simulate authentication by passing an // X-MS-CLIENT-PRINCIPAL header in the same form that Azure Functions would supply. // (To test against a deployed instance, we would need to provide a real token, because // Azure will block any requests that don't. Also, it won't pass through any // X-MS-CLIENT-PRINCIPAL header from the outside.) var claimsClient = new UnauthenticatedClaimsService(new Uri(serviceUrl)); var appServiceClientPrincipal = new JObject( new JProperty( "claims", new JArray( new JObject( new JProperty("typ", "http://schemas.microsoft.com/identity/claims/objectidentifier"), new JProperty("val", this.clientOid))))); claimsClient.HttpClient.DefaultRequestHeaders.Add( "X-MS-CLIENT-PRINCIPAL", Convert.ToBase64String(Encoding.UTF8.GetBytes(appServiceClientPrincipal.ToString(Formatting.None)))); this.claimsServiceClient = claimsClient; }
public PlaceController(IAdministratorRepository administratorRepository, IPlaceRepository placeRepository, IPlaceService placeService, IClaimsService claimsService) { _administratorRepository = administratorRepository; _placeRepository = placeRepository; _placeService = placeService; _claimsService = claimsService; }
/// <summary> /// Constructor method for ClaimsController /// </summary> /// <param name="claimsService"></param> public ClaimsController(IClaimsService claimsService, IHttpContextAccessor httpContextAccessor , IOptions <AppSettings> appSettings) { _claimsService = claimsService; _httpContextAccessor = httpContextAccessor; _appSettings = appSettings; }
/// <summary> /// Gets a permission result for a claim permissions for a target resource and /// access type /// </summary> /// <remarks> /// Gets a permission result for a claim permissions for a target resource and /// access type /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='claimPermissionsId'> /// An identifier uniquely associated with a claim permissions /// </param> /// <param name='tenantId'> /// The tenant within which the request should operate /// </param> /// <param name='resourceUri'> /// </param> /// <param name='accessType'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> GetClaimPermissionsPermissionAsync(this IClaimsService operations, string claimPermissionsId, string tenantId, string resourceUri, string accessType, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetClaimPermissionsPermissionWithHttpMessagesAsync(claimPermissionsId, tenantId, resourceUri, accessType, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates an <see cref="OpenApiClientResourceAccessEvaluator"/>. /// </summary> /// <param name="claimsClient">The claims service client.</param> /// <param name="logger">The logger.</param> public OpenApiClientResourceAccessEvaluator( IClaimsService claimsClient, ILogger <OpenApiClientResourceAccessEvaluator> logger) { this.claimsClient = claimsClient; this.logger = logger; }
public async Task InvokeAsync(HttpContext context, UsersDb db, IClaimsService claimsService) { if (!context.User.Identity.IsAuthenticated || !context.User.TryGetEmail(out var email)) { await _next(context); return; } var identity = context.User.Identities.First(); var user = await db.Users.FirstOrDefaultAsync(x => x.Email == email); if (user == null) { await _next(context); return; } foreach (var claim in await claimsService.GetClaimsAsync(user.Id)) { identity.AddClaim(new Claim(claim.ClaimType, claim.ClaimValue, claim.ClaimValueType, "theapp")); } await _next(context); }
public EventController(IAdministratorRepository administratorRepository, IPlaceRepository placeRepository, IEventRepository eventRepository, IEventService eventService, IClaimsService claimsService) { _administratorRepository = administratorRepository; _placeRepository = placeRepository; _eventRepository = eventRepository; _eventService = eventService; _claimsService = claimsService; }
public ChatHub(IMessageService messageService, IClaimsService claimsService, ICacheService cacheService, IPubSub pubSub, INotificationService notificationService) { _messageService = messageService; _claimsService = claimsService; _cacheService = cacheService; _pubSub = pubSub; _notificationService = notificationService; }
public JwtService( IJwtSettings jwtSettings, IClaimsService claimsService ) { _jwtSettings = jwtSettings; _claimsService = claimsService; }
public async Task <DeleteEntityByIdPayload> DeleteClaimAsync([Service] IClaimsService service, Guid id, CancellationToken cancellationToken) { return(new DeleteEntityByIdPayload { Success = await service.DeleteByIdAsync(id, cancellationToken) }); }
public UsersController(IAuthorizationService authorizationService, IClaimsService claimsService, UsersDb db) { _authorizationService = authorizationService; _claimsService = claimsService; _db = db; }
public UserService( IHttpContextAccessor contextAccessor, IClaimsService claimsService, ICrudPageableRepositoryAsync <User, string> userRepository, ICrudPageableRepositoryAsync <RefreshToken, string> refreshTokenRepository) : base(contextAccessor) { _claimsService = claimsService; _userRepository = userRepository; _refreshTokenRepository = refreshTokenRepository; }
public AuthManagementController(ILogService logService, UserManager <IdentityUser> userManager, IOptionsMonitor <JwtConfig> optionsMonitor, RoleManager <IdentityRole> roleManager, IAspNetUserRolesService aspNetUserRolesService, IClaimsService claimsService) { _userManager = userManager; _jwtConfig = optionsMonitor.CurrentValue; _roleManager = roleManager; _aspNetUserRolesService = aspNetUserRolesService; _claimsService = claimsService; _logService = logService; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultTokenService" /> class. This overloaded constructor is deprecated and will be removed in 3.0.0. /// </summary> /// <param name="context">The context.</param> /// <param name="claimsProvider">The claims provider.</param> /// <param name="referenceTokenStore">The reference token store.</param> /// <param name="creationService">The signing service.</param> /// <param name="events">The events service.</param> /// <param name="logger">The logger.</param> public DefaultTokenService(IHttpContextAccessor context, IClaimsService claimsProvider, IReferenceTokenStore referenceTokenStore, ITokenCreationService creationService, IEventService events, ILogger <DefaultTokenService> logger) { Logger = logger; Context = context; ClaimsProvider = claimsProvider; ReferenceTokenStore = referenceTokenStore; CreationService = creationService; Events = events; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultTokenService" /> class. This overloaded constructor is deprecated and will be removed in 3.0.0. /// </summary> /// <param name="context">The context.</param> /// <param name="claimsProvider">The claims provider.</param> /// <param name="grants">The grants.</param> /// <param name="creationService">The signing service.</param> /// <param name="events">The events service.</param> /// <param name="logger">The logger.</param> public DefaultTokenService(IHttpContextAccessor context, IClaimsService claimsProvider, IPersistedGrantService grants, ITokenCreationService creationService, IEventService events, ILogger <DefaultTokenService> logger) { _logger = logger; _context = context; _claimsProvider = claimsProvider; _grants = grants; _creationService = creationService; _events = events; }
public HomeService(IRepository <Post> postRepository, IRepository <Friend> friendRepository, IRepository <GroupJoinedUser> groupsUsersRepository, IClaimsService claimsService, IImageService imageService, IMapper mapper) { _postRepository = postRepository; _friendRepository = friendRepository; _groupsUsersRepository = groupsUsersRepository; _claimsService = claimsService; _imageService = imageService; _mapper = mapper; }
public CustomTokenService(IClaimsService claimsProvider , IReferenceTokenStore referenceTokenStore , ITokenCreationService creationService , IHttpContextAccessor contextAccessor , ISystemClock clock , IKeyMaterialService keyMaterialService , ILogger <DefaultTokenService> logger) : base(claimsProvider, referenceTokenStore, creationService, contextAccessor, clock, keyMaterialService, logger) { }
public PermissionsService(BaseDbContext dbContext, ILocalizationService localizationService, ILogger <PermissionsService> logger, IClaimsService claimsService) { _dbContext = dbContext; _localizationService = localizationService; _logger = logger; _claimsService = claimsService; }
public async Task InvokeAsync(HttpContext httpContext, IClaimsService claimsService) { var user = httpContext.User; if (user != null && user.Identity.IsAuthenticated) { claimsService.LoadClaims(user); } await _next(httpContext); }
public SecurityGroupService(BaseDbContext dbContext, ILogger <SecurityGroupService> logger, ILocalizationService localizationService, IClaimsService claimsService) { _dbContext = dbContext; _logger = logger; _localizationService = localizationService; _claimsService = claimsService; }
public ClaimsUserService(IClaimsService claimsService, IUserService innerUserService) { if (claimsService == null) { throw new ArgumentNullException(nameof(claimsService)); } if (innerUserService == null) { throw new ArgumentNullException(nameof(innerUserService)); } this.claimsService = claimsService; this.innerUserService = innerUserService; }
static void CallProxy(IClaimsService proxy) { var proxyChannel = proxy as IClientChannel; if (proxy != null) { proxyChannel.Open(); } try { proxy.ShowClaims(); proxy.DoSecret(); proxy.DoTopSecret(); ((IClientChannel)proxy).Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); } }
public ClaimsController() { policyService = new PolicyService(); claimsService = new ClaimsService(); }
public ClaimsApiController() { claimsService = new ClaimsService(); }