<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Tweek.ApiService.Addons;
using System.Security.Claims;
using Microsoft.AspNetCore.Rewrite;

namespace Tweek.ApiService.NetCore.Security
{
    public class TweekLegacySupport : ITweekAddon
    {
        public void Install(IApplicationBuilder builder, IConfiguration configuration)
        {
            builder.UseRewriter(new RewriteOptions().AddRewrite("configurations/([^?]+)[?]?(.*)", "v1/keys/$1?$tweeklegacy=tweeklegacy&$ignoreKeyTypes=true&$2", true));
            builder.UseRewriter(new RewriteOptions().AddRewrite("context/([^?]+)[?]?(.*)", "v1/context/$1?$tweeklegacy=tweeklegacy&$2", true));
            builder.Use(next => (ctx) => {
              if (ctx.Request.Query.ContainsKey("$tweeklegacy"))
                {
                    ctx.User.AddIdentity(new ClaimsIdentity(new[] { new Claim("iss", "TweekLegacy") }));
                }
                return next(ctx);
                }
            );
        }
    }
}
<commit_msg>fix context redirect<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Tweek.ApiService.Addons;
using System.Security.Claims;
using Microsoft.AspNetCore.Rewrite;

namespace Tweek.ApiService.NetCore.Security
{
    public class TweekLegacySupport : ITweekAddon
    {
        public void Install(IApplicationBuilder builder, IConfiguration configuration)
        {
            builder.UseRewriter(new RewriteOptions().AddRewrite("^configurations/([^?]+)[?]?(.*)", "v1/keys/$1?$tweeklegacy=tweeklegacy&$ignoreKeyTypes=true&$2", true));
            builder.UseRewriter(new RewriteOptions().AddRewrite("^context/([^?]+)[?]?(.*)", "v1/context/$1?$tweeklegacy=tweeklegacy&$2", true));
            builder.Use(next => (ctx) => {
              if (ctx.Request.Query.ContainsKey("$tweeklegacy"))
                {
                    ctx.User.AddIdentity(new ClaimsIdentity(new[] { new Claim("iss", "TweekLegacy") }));
                }
                return next(ctx);
                }
            );
        }
    }
}

{'fraction_non_alphanumeric': 0.14436471084845925, 'fraction_numerical': 0.005065428450823132, 'mean_word_length': 3.093264248704663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6881124', 'n_tokens_mistral': 717, 'n_tokens_neox': 688, 'n_words': 104}