public void IsAuthorizedThrowsException(Guid scopeId, ClaimsPrincipal user, ILoggableEntity entity)
 {
     if (!isAuthorized(scopeId, user))
     {
         string message = string.Format("Access denied: The current user context is not authorized for the scope {0}", AuthorizationScopes.GetScope(scopeId).Name);
         throw new UnauthorizedAccessException(message);
     }
 }
Exemplo n.º 2
0
        public AuditableLog(ILoggableEntity entity, string observation, AuditableLogTypesEnum auditLogTypesEnum, int createdById, string createdBy)
        {
            if (!(entity is object))
            {
                throw new AuditableLogException($"Varivavel {nameof(entity)} não pode ser null");
            }

            EntityType       = entity.Type;
            EntityId         = entity.EntityId;
            EntityIdentifier = entity.EntityIdentifier;

            Observation  = $"O Usuário '{createdBy}' " + observation;
            AuditLogType = (int)auditLogTypesEnum;
            CreatedById  = createdById;
            CreatedBy    = createdBy;
            CreatedOn    = DateTime.Now;
        }
Exemplo n.º 3
0
        public void LogSecurityAuditFailure(ClaimsPrincipal userContext, ILoggableEntity entity, EventCategory category)
        {
            AppConfig appConfig = configurationRepository.GetAppConfig();

            if (appConfig.SecurityAuditingState == SecurityAuditingState.Success)
            {
                AuditEvent auditEvent = new AuditEvent
                {
                    Id            = Guid.NewGuid(),
                    Target        = userContext.GetName(),
                    EventCategory = category,
                    UserId        = userContext.GetUserId(),
                    UserDisplay   = userContext.GetName(),
                    Time          = DateTime.Now,
                    EventResult   = EventResult.Failure
                };
                Task.Run(() => auditRepository.InsertAuditEvent(auditEvent));
            }
        }
Exemplo n.º 4
0
 public void LogSecurityAuditSuccess(ClaimsPrincipal userContext, ILoggableEntity entity, EventCategory category)
 {
 }
 public void IsAuthorizedThrowsException(Guid scopeId, ClaimsPrincipal user, ILoggableEntity entity, EventCategory category)
 {
 }