<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IdentityServer4.Validation;
using IdentityServer4.Models;
using IdentityServer4;
using IdentityServer4.Test;

namespace IdServer
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddIdentityServer()
                .AddTemporarySigningCredential()
                .AddInMemoryIdentityResources(new List<IdentityResource>
                {
                    new IdentityResources.OpenId(),
                    new IdentityResources.Profile(),
                })
                .AddInMemoryClients(new Client[]
                {
                     new Client
                    {
                        ClientId = "WebApp",
                        ClientName = "<NAME>",

                        AllowedGrantTypes = GrantTypes.Implicit,

                        // Where to redirect to after login
                        RedirectUris = { "http://localhost:4324/signin-oidc" },

                        // Where to redirect to after logout
                        PostLogoutRedirectUris = { "http://localhost:4324/signout-callback-oidc" },

                        // Scopes that client has access to
                        AllowedScopes = new List<string>
                        {
                            IdentityServerConstants.StandardScopes.OpenId,
                            IdentityServerConstants.StandardScopes.Profile,
                        },

                        // Secret for client authentication
                        ClientSecrets =
                        {
                            new Secret("WebApp.Secret")
                        },

                    }
               })
                .AddInMemoryApiResources( Enumerable.Empty<ApiResource>() )
                // The AddTestUsers extension method does a couple of things under the hood
                //  - adds support for the resource owner password grant
                //  - adds support to user related services typically used by a login UI(we’ll use that in the next quickstart)
                //  - adds support for a profile service based on the test users(you’ll learn more about that in the next quickstart)
                .AddTestUsers(new List<TestUser>
                {
                    new TestUser
                    {
                        SubjectId = "Alice_has_only_basic_authentication",
                        Username = "alice",
                        Password = "password"
                    },
                    new TestUser
                    {
                        SubjectId = "Bob_is_totally_unknown",
                        Username = "bob",
                        Password = "password"
                    },
                    new TestUser
                    {
                        SubjectId = "Carol_is_Basic_and_Oidc_registered",
                        Username = "carol",
                        Password = "password"
                    }
                } );
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();

            app.UseDeveloperExceptionPage();

            app.UseIdentityServer();

            app.UseGoogleAuthentication(new GoogleOptions
            {
                AuthenticationScheme = "Google",
                SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
                ClientId = "708996912208-9m4dkjb5hscn7cjrn5u0r4tbgkbj1fko.apps.googleusercontent.com",
                ClientSecret = "<KEY>"
            });

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
    }
}
<commit_msg>Added trace in Console of in/out headers in IdServer.<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IdentityServer4.Validation;
using IdentityServer4.Models;
using IdentityServer4;
using IdentityServer4.Test;

namespace IdServer
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddIdentityServer()
                .AddTemporarySigningCredential()
                .AddInMemoryIdentityResources(new List<IdentityResource>
                {
                    new IdentityResources.OpenId(),
                    new IdentityResources.Profile(),
                })
                .AddInMemoryClients(new Client[]
                {
                     new Client
                    {
                        ClientId = "WebApp",
                        ClientName = "<NAME>",

                        AllowedGrantTypes = GrantTypes.Implicit,

                        // Where to redirect to after login
                        RedirectUris = { "http://localhost:4324/signin-oidc" },

                        // Where to redirect to after logout
                        PostLogoutRedirectUris = { "http://localhost:4324/signout-callback-oidc" },

                        // Scopes that client has access to
                        AllowedScopes = new List<string>
                        {
                            IdentityServerConstants.StandardScopes.OpenId,
                            IdentityServerConstants.StandardScopes.Profile,
                        },

                        // Secret for client authentication
                        ClientSecrets =
                        {
                            new Secret("WebApp.Secret")
                        },

                    }
               })
                .AddInMemoryApiResources( Enumerable.Empty<ApiResource>() )
                // The AddTestUsers extension method does a couple of things under the hood
                //  - adds support for the resource owner password grant
                //  - adds support to user related services typically used by a login UI(we’ll use that in the next quickstart)
                //  - adds support for a profile service based on the test users(you’ll learn more about that in the next quickstart)
                .AddTestUsers(new List<TestUser>
                {
                    new TestUser
                    {
                        SubjectId = "Alice_has_only_basic_authentication",
                        Username = "alice",
                        Password = "password"
                    },
                    new TestUser
                    {
                        SubjectId = "Bob_is_totally_unknown",
                        Username = "bob",
                        Password = "password"
                    },
                    new TestUser
                    {
                        SubjectId = "Carol_is_Basic_and_Oidc_registered",
                        Username = "carol",
                        Password = "password"
                    }
                } );
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();

            app.UseDeveloperExceptionPage();

            app.Use( async (context, next) =>
            {
                foreach( var h in context.Request.Headers )
                {
                    Console.WriteLine( $"==> Header: {h.Key} => {h.Value}" );
                    foreach( var v in h.Value )
                    {
                        Console.WriteLine( $"          : {h.Key} => {h.Value}" );
                    }
                }
                await next();
                foreach( var h in context.Response.Headers )
                {
                    Console.WriteLine( $"<== Header: {h.Key} => {h.Value}" );
                    foreach( var v in h.Value )
                    {
                        Console.WriteLine( $"          : {h.Key} => {h.Value}" );
                    }
                }
            } );

            app.UseIdentityServer();

            app.UseGoogleAuthentication(new GoogleOptions
            {
                AuthenticationScheme = "Google",
                SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
                ClientId = "<KEY>",
                ClientSecret = "<KEY>"
            });

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
    }
}

{'fraction_non_alphanumeric': 0.07222874213165476, 'fraction_numerical': 0.00597460791635549, 'mean_word_length': 1.2691842168966352, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 22, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5308490', 'n_tokens_mistral': 2172, 'n_tokens_neox': 1983, 'n_words': 494}