diff --git a/.gitignore b/.gitignore
index bf793ed..d871e54 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,41 +1,437 @@
-# Autosave files
-*~
-
-# build
-[Oo]bj/
-[Bb]in/
-packages/
-TestResults/
-
-# globs
-Makefile.in
-*.DS_Store
-*.sln.cache
-*.suo
-*.cache
-*.pidb
-*.userprefs
-*.usertasks
-config.log
-config.make
-config.status
-aclocal.m4
-install-sh
-autom4te.cache/
-*.user
-*.tar.gz
-tarballs/
-test-results/
-Thumbs.db
-.vs/
-
-# Mac bundle stuff
-*.dmg
-*.app
-
-# resharper
-*_Resharper.*
-*.Resharper
-
-# dotCover
-*.dotCover
+
+# Created by https://www.gitignore.io/api/Rider,VisualStudio,VisualStudioCode
+# Edit at https://www.gitignore.io/?templates=Rider,VisualStudio,VisualStudioCode
+
+### Rider ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+# *.iml
+# *.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+### VisualStudioCode ###
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+### VisualStudioCode Patch ###
+# Ignore all local history of files
+.history
+
+### VisualStudio ###
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# End of https://www.gitignore.io/api/Rider,VisualStudio,VisualStudioCode
diff --git a/IdentityServer/IdentityServer.csproj b/IdentityServer/IdentityServer.csproj
index 2baaddb..d1dc0f9 100755
--- a/IdentityServer/IdentityServer.csproj
+++ b/IdentityServer/IdentityServer.csproj
@@ -1,16 +1,14 @@
- netcoreapp2.0
+ netcoreapp3.1
+ latest
-
-
+
+
+
-
-
-
-
-
+
diff --git a/IdentityServer/Startup.cs b/IdentityServer/Startup.cs
index 14200ed..b43c5cb 100755
--- a/IdentityServer/Startup.cs
+++ b/IdentityServer/Startup.cs
@@ -1,54 +1,91 @@
-using IdentityServer4.Services;
-using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
namespace IdentityServer
-{
+{
public class Startup
{
+ private readonly IConfiguration _configuration;
+
public Startup(IConfiguration configuration)
{
- Configuration = configuration;
+ _configuration = configuration;
}
- public IConfiguration Configuration { get; }
-
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
+ #region Called for ASPNETCORE_ENVIRONMENT=Development
+ public void ConfigureDevelopmentServices(IServiceCollection services)
{
- services.AddMvc();
+ services
+ .AddControllersWithViews()
+ .AddRazorRuntimeCompilation()
+ .AddNewtonsoftJson(options =>
+ {
+ options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
+ options.SerializerSettings.Formatting = Formatting.Indented;
+ });
- // Configuração do Identity Server In-Memory
- services.AddIdentityServer()
- .AddDeveloperSigningCredential()
- .AddInMemoryIdentityResources(Config.GetIdentityResources())
- .AddInMemoryClients(Config.GetClients())
+ services
+ .AddIdentityServer()
+ .AddDeveloperSigningCredential()
+ .AddInMemoryIdentityResources(Config.GetIdentityResources())
+ .AddInMemoryClients(Config.GetClients())
.AddTestUsers(Config.GetUsers());
}
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ public void ConfigureDevelopment(IApplicationBuilder app, IWebHostEnvironment env)
{
- if (env.IsDevelopment())
+ app.UseDeveloperExceptionPage();
+ app.UseIdentityServer();
+ app.UseHttpsRedirection();
+ app.UseStaticFiles();
+ app.UseRouting();
+ app.UseEndpoints(endpoints =>
{
- app.UseBrowserLink();
- app.UseDeveloperExceptionPage();
- }
- else
+ endpoints.MapControllerRoute(
+ "default", "{controller=Home}/{action=Index}/{id?}"
+ );
+ });
+ }
+ #endregion
+
+ #region Called for ASPNETCORE_ENVIRONMENT=Production
+ public void ConfigureProductionServices(IServiceCollection services)
+ {
+ services
+ .AddControllersWithViews()
+ .AddRazorRuntimeCompilation()
+ .AddNewtonsoftJson(options =>
+ {
+ options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
+ });
+
+ services
+ .AddIdentityServer()
+ .AddDeveloperSigningCredential()
+ .AddInMemoryIdentityResources(Config.GetIdentityResources())
+ .AddInMemoryClients(Config.GetClients())
+ .AddTestUsers(Config.GetUsers());
+ }
+
+ public void ConfigureProduction(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ app.UseExceptionHandler("/Home/Error");
+ app.UseIdentityServer();
+ app.UseHsts();
+ app.UseHttpsRedirection();
+ app.UseStaticFiles();
+ app.UseRouting();
+ app.UseAuthorization();
+ app.UseEndpoints(endpoints =>
{
- app.UseExceptionHandler("/Home/Error");
- }
-
- //Habilitando o uso do Identity Server no nosso projeto
- app.UseIdentityServer();
-
- //Habilitando o uso de arquivos estáticos (Html, Css e etc) do nosso projeto
- app.UseStaticFiles();
-
- //Habilitando o uso de rota no projeto
- app.UseMvcWithDefaultRoute();
+ endpoints.MapControllerRoute(
+ "default", "{controller=Home}/{action=Index}/{id?}"
+ );
+ });
}
+ #endregion
}
}
diff --git a/IdentityServer/Views/Account/Login.cshtml b/IdentityServer/Views/Account/Login.cshtml
index 84a02b2..32856da 100755
--- a/IdentityServer/Views/Account/Login.cshtml
+++ b/IdentityServer/Views/Account/Login.cshtml
@@ -5,7 +5,7 @@
Login
- @Html.Partial("_ValidationSummary")
+
diff --git a/IdentityServer/Views/Consent/Index.cshtml b/IdentityServer/Views/Consent/Index.cshtml
index b3a2f64..c45544c 100755
--- a/IdentityServer/Views/Consent/Index.cshtml
+++ b/IdentityServer/Views/Consent/Index.cshtml
@@ -16,7 +16,7 @@
- @Html.Partial("_ValidationSummary")
+
@@ -49,7 +49,7 @@
@foreach (var scope in Model.ResourceScopes)
{
- @Html.Partial("_ScopeListItem", scope)
+
}
diff --git a/IdentityServer/Views/Shared/Error.cshtml b/IdentityServer/Views/Shared/Error.cshtml
index 90ab6fc..5c22de7 100755
--- a/IdentityServer/Views/Shared/Error.cshtml
+++ b/IdentityServer/Views/Shared/Error.cshtml
@@ -1,11 +1,13 @@
@using Microsoft.AspNetCore.Hosting
+@using Microsoft.Extensions.Hosting
@model ErrorViewModel
-@inject IHostingEnvironment host
+
+@inject IWebHostEnvironment Host
@{
var error = Model?.Error?.Error;
- var errorDescription = host.IsDevelopment() ? Model?.Error?.ErrorDescription : null;
- var request_id = Model?.Error?.RequestId;
+ var errorDescription = Host.IsDevelopment() ? Model?.Error?.ErrorDescription : null;
+ var requestId = Model?.Error?.RequestId;
}
@@ -33,9 +35,9 @@
}
- @if (request_id != null)
+ @if (requestId != null)
{
-
Request Id: @request_id
+
Request Id: @requestId
}
diff --git a/iMastersApp/Startup.cs b/iMastersApp/Startup.cs
index 6c5d512..69ae908 100644
--- a/iMastersApp/Startup.cs
+++ b/iMastersApp/Startup.cs
@@ -1,75 +1,119 @@
-using System.IdentityModel.Tokens.Jwt;
-using IdentityServer4;
+using System.IdentityModel.Tokens.Jwt;
+using IdentityServer4;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
namespace iMastersApp
-{
+{
public class Startup
{
+ private readonly IConfiguration _configuration;
+
public Startup(IConfiguration configuration)
{
- Configuration = configuration;
+ _configuration = configuration;
}
- public IConfiguration Configuration { get; }
-
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
+ private static void ConfigureIdentityServerOnClient(IServiceCollection services)
{
- services.AddMvc();
-
//Exibe as claims de maneira mais "amigável"
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
-
+
//Adciona o serviço de autenticação
- services.AddAuthentication(options =>
- {
- //Nosso esquema default será baseado em cookie
- options.DefaultScheme = "Cookies";
-
- //Como precisamos recuperar os dados depois do login, utilizamos o OpenID Connect que por padrão utiliza o escopo do Profile
- options.DefaultChallengeScheme = "oidc";
- })
+ services
+ .AddAuthentication(options =>
+ {
+ //Nosso esquema default será baseado em cookie
+ options.DefaultScheme = "Cookies";
+ //Como precisamos recuperar os dados depois do login, utilizamos o OpenID Connect que por padrão utiliza o escopo do Profile
+ options.DefaultChallengeScheme = "oidc";
+ })
.AddCookie("Cookies")
.AddOpenIdConnect("oidc", options =>
{
options.SignInScheme = "Cookies";
-
+
//Aponta para o nosso servidor de autenticação
- options.Authority = "http://localhost:5000";
+ options.Authority = "http://localhost:32182";
options.RequireHttpsMetadata = false;
-
- //Nome da nossa aplicação que tentará se autenticar no nosso servidor de identidade
+
+ //Nome da nossa aplicação que tentará se autenticar no nosso servidor de identidade
//Observe que ela possui o mesmo nome da app que liberamos no nosso servidor de identidade
options.ClientId = "iMastersApp";
- options.SaveTokens = true;
-
- //Adicionamos o scopo do e-mail para utilizarmos a claim de e-mail.
- options.Scope.Add(IdentityServerConstants.StandardScopes.Email);
-
+ options.SaveTokens = true;
+
+ //Adicionamos o scopo do e-mail para utilizarmos a claim de e-mail.
+ options.Scope.Add(IdentityServerConstants.StandardScopes.Email);
+
options.Scope.Add("custom.profile");
});
}
+
+ #region Called for ASPNETCORE_ENVIRONMENT=Development
+ public void ConfigureDevelopmentServices(IServiceCollection services)
+ {
+ services
+ .AddControllersWithViews()
+ .AddRazorRuntimeCompilation()
+ .AddNewtonsoftJson(options =>
+ {
+ options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
+ options.SerializerSettings.Formatting = Formatting.Indented;
+ });
+
+ ConfigureIdentityServerOnClient(services);
+ }
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ public void ConfigureDevelopment(IApplicationBuilder app, IWebHostEnvironment env)
{
- if (env.IsDevelopment())
+ app.UseDeveloperExceptionPage();
+ app.UseAuthentication();
+ app.UseHttpsRedirection();
+ app.UseStaticFiles();
+ app.UseRouting();
+ app.UseAuthorization();
+ app.UseEndpoints(endpoints =>
{
- app.UseDeveloperExceptionPage();
- }
+ endpoints.MapControllerRoute(
+ "default", "{controller=Home}/{action=Index}/{id?}"
+ );
+ });
+ }
+ #endregion
- //Habilitando o uso da autenticação do Identity Server no nosso projeto
- app.UseAuthentication();
-
- //Habilitando o uso de arquivos estáticos (Html, Css e etc) do nosso projeto
- app.UseStaticFiles();
-
- //Habilitando o uso de rota no projeto
- app.UseMvcWithDefaultRoute();
+ #region Called for ASPNETCORE_ENVIRONMENT=Production
+ public void ConfigureProductionServices(IServiceCollection services)
+ {
+ services
+ .AddControllersWithViews()
+ .AddRazorRuntimeCompilation()
+ .AddNewtonsoftJson(options =>
+ {
+ options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
+ });
+
+ ConfigureIdentityServerOnClient(services);
+ }
+
+ public void ConfigureProduction(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ app.UseExceptionHandler("/Home/Error");
+ app.UseAuthentication();
+ app.UseHsts();
+ app.UseHttpsRedirection();
+ app.UseStaticFiles();
+ app.UseRouting();
+ app.UseAuthorization();
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllerRoute(
+ "default", "{controller=Home}/{action=Index}/{id?}"
+ );
+ });
}
+ #endregion
}
}
diff --git a/iMastersApp/iMastersApp.csproj b/iMastersApp/iMastersApp.csproj
index 0289b09..229a45b 100644
--- a/iMastersApp/iMastersApp.csproj
+++ b/iMastersApp/iMastersApp.csproj
@@ -1,20 +1,14 @@
-
- netcoreapp2.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ netcoreapp3.1
+ latest
+
+
+
+
+
+
+
+