public async Task InvokeAsync(HttpContext context, IHtfContext htfContext, ITeamLogic teamLogic)
        {
            if (context.Request.Headers.ContainsKey(IDENTIFICATION_HEADER) && context.Request.Headers[IDENTIFICATION_HEADER].Count == 1)
            {
                var    overlordIdentification = Environment.GetEnvironmentVariable("OVERLORD_IDENTIFICATION");
                String identification         = context.Request.Headers[IDENTIFICATION_HEADER].Single();
                htfContext.Identification = identification;
                if (identification == overlordIdentification)
                {
                    htfContext.IsIdentifiedAsAdmin = true;
                }
                Guid identificationGuid = Guid.Empty;
                if (Guid.TryParse(identification.Base64Decode(), out identificationGuid))
                {
                    Team team = await teamLogic.FindTeamByIdentification(identification);

                    if (team != null)
                    {
                        htfContext.IsIdentified = true;
                        htfContext.Team         = new Common.Model.Team {
                            Id = team.Id, Name = team.Name
                        };
                    }
                }
            }
            await _next(context);
        }
示例#2
0
 public Challenge10(IHtfContext htfContext, ITeamLogic teamLogic, IChallengeLogic challengeLogic,
                    IDashboardLogic dashboardLogic, IHistoryLogic historyLogic, IImageLogic imageLogic)
     : base(htfContext, teamLogic, challengeLogic, dashboardLogic, historyLogic)
 {
     _htfContext = htfContext;
     _imageLogic = imageLogic;
 }
示例#3
0
 public Challenge13(IHtfContext htfContext, ITeamLogic teamLogic, IChallengeLogic challengeLogic,
                    IDashboardLogic dashboardLogic, IHistoryLogic historyLogic, IMemoryCache memoryCache)
     : base(htfContext, teamLogic, challengeLogic, dashboardLogic, historyLogic)
 {
     _cache  = memoryCache;
     _client = new RestClient("https://api.mapbox.com/geocoding/v5/mapbox.places/");
 }
示例#4
0
 public Challenge18(IHtfContext htfContext, ITeamLogic teamLogic, IChallengeLogic challengeLogic,
                    IDashboardLogic dashboardLogic, IHistoryLogic historyLogic, IMemoryCache memoryCache)
     : base(htfContext, teamLogic, challengeLogic, dashboardLogic, historyLogic)
 {
     _cache  = memoryCache;
     _client = new RestClient("https://pokeapi.co/api/v2/pokemon/");
 }
示例#5
0
        public async Task InvokeAsync(HttpContext context, IHtfContext htfContext)
        {
            var overlordIdentification = Environment.GetEnvironmentVariable("OVERLORD_IDENTIFICATION");

            if (!String.IsNullOrEmpty(htfContext.Identification) && htfContext.Identification != overlordIdentification)
            {
                if (_throttleIndex.ContainsKey(htfContext.Identification))
                {
                    DateTime lastRequest = _throttleIndex[htfContext.Identification];
                    if (DateTime.UtcNow - lastRequest < THROTTLE_SPAN)
                    {
                        context.Response.StatusCode = 429;
                        await context.Response.WriteAsync($"The Artifact does not allow multiple interactions without delaying for at least {THROTTLE_SPAN.Seconds} seconds!");

                        return;
                    }
                    _throttleIndex[htfContext.Identification] = DateTime.UtcNow;
                }
                else
                {
                    _throttleIndex.Add(htfContext.Identification, DateTime.UtcNow);
                }
            }
            await _next(context);
        }
示例#6
0
 public Challenge01(IHtfContext htfContext, ITeamLogic teamLogic, IChallengeLogic challengeLogic,
                    IDashboardLogic dashboardLogic, IHistoryLogic historyLogic)
     : base(htfContext, teamLogic, challengeLogic, dashboardLogic, historyLogic)
 {
     _historyLogic   = historyLogic;
     _teamLogic      = teamLogic;
     _challengeLogic = challengeLogic;
 }
示例#7
0
        public async Task InvokeAsync(HttpContext context, IHtfContext htfContext)
        {
            var displayUri = new Uri(context.Request.GetDisplayUrl());

            htfContext.RequestUri = displayUri.ToString();
            htfContext.HostUri    = displayUri.Authority;
            await _next(context);
        }
示例#8
0
 protected ChallengeBase(
     IHtfContext htfContext,
     ITeamLogic teamLogic, IChallengeLogic challengeLogic, IDashboardLogic dashboardLogic, IHistoryLogic historyLogic)
 {
     _htfContext     = htfContext;
     _teamLogic      = teamLogic;
     _challengeLogic = challengeLogic;
     _dashboardLogic = dashboardLogic;
     _historyLogic   = historyLogic;
 }
示例#9
0
 public ChallengeEngine(IHtfContext context, ITeamLogic teamLogic, IChallengeLogic challengeLogic,
                        IChallenge01 challenge01, IChallenge02 challenge02, IChallenge03 challenge03, IChallenge04 challenge04, IChallenge05 challenge05,
                        IChallenge06 challenge06, IChallenge07 challenge07, IChallenge08 challenge08, IChallenge09 challenge09, IChallenge10 challenge10,
                        IChallenge11 challenge11, IChallenge12 challenge12, IChallenge13 challenge13, IChallenge14 challenge14, IChallenge15 challenge15,
                        IChallenge16 challenge16, IChallenge17 challenge17, IChallenge18 challenge18, IChallenge19 challenge19, IChallenge20 challenge20)
 {
     _context          = context;
     _teamLogic        = teamLogic;
     _challengeLogic   = challengeLogic;
     _challengeLibrary = new Dictionary <Identifier, IChallenge>
     {
         { Identifier.Challenge01, challenge01 }, { Identifier.Challenge02, challenge02 },
         { Identifier.Challenge03, challenge03 }, { Identifier.Challenge04, challenge04 },
         { Identifier.Challenge05, challenge05 }, { Identifier.Challenge06, challenge06 },
         { Identifier.Challenge07, challenge07 }, { Identifier.Challenge08, challenge08 },
         { Identifier.Challenge09, challenge09 }, { Identifier.Challenge10, challenge10 },
         { Identifier.Challenge11, challenge11 }, { Identifier.Challenge12, challenge12 },
         { Identifier.Challenge13, challenge13 }, { Identifier.Challenge14, challenge14 },
         { Identifier.Challenge15, challenge15 }, { Identifier.Challenge16, challenge16 },
         { Identifier.Challenge17, challenge17 }, { Identifier.Challenge18, challenge18 },
         { Identifier.Challenge19, challenge19 }, { Identifier.Challenge20, challenge20 }
     };
 }
示例#10
0
 public AdministratorFilter(IHtfContext htfContext)
 {
     _htfContext = htfContext;
 }
示例#11
0
 /// <summary>
 /// CHALLENGE 08:
 /// Variable parameters
 /// </summary>
 public Challenge09(IHtfContext htfContext, ITeamLogic teamLogic, IChallengeLogic challengeLogic,
                    IDashboardLogic dashboardLogic, IHistoryLogic historyLogic)
     : base(htfContext, teamLogic, challengeLogic, dashboardLogic, historyLogic)
 {
 }
示例#12
0
 public IdentificationFilter(IHtfContext htfContext)
 {
     _htfContext = htfContext;
 }