diff --git a/Samples/oidc-hs256/.bowerrc b/Samples/oidc-hs256/.bowerrc new file mode 100644 index 0000000..6406626 --- /dev/null +++ b/Samples/oidc-hs256/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "wwwroot/lib" +} diff --git a/Samples/oidc-hs256/.gitignore b/Samples/oidc-hs256/.gitignore new file mode 100644 index 0000000..3ea391d --- /dev/null +++ b/Samples/oidc-hs256/.gitignore @@ -0,0 +1,237 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# 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 + +# 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 +# TODO: 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 + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# 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 +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# 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 + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# 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 + +# FAKE - F# Make +.fake/ + +# Bower packages +wwwroot/lib diff --git a/Samples/oidc-hs256/Auth0Settings.cs b/Samples/oidc-hs256/Auth0Settings.cs new file mode 100644 index 0000000..d1357d5 --- /dev/null +++ b/Samples/oidc-hs256/Auth0Settings.cs @@ -0,0 +1,13 @@ +namespace AspNetCoreOidcSample +{ + public class Auth0Settings + { + public string Domain { get; set; } + + public string CallbackUrl { get; set; } + + public string ClientId { get; set; } + + public string ClientSecret { get; set; } + } +} diff --git a/Samples/oidc-hs256/Controllers/AccountController.cs b/Samples/oidc-hs256/Controllers/AccountController.cs new file mode 100644 index 0000000..fc736d9 --- /dev/null +++ b/Samples/oidc-hs256/Controllers/AccountController.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Mvc; + +namespace AspNetCoreOidcSample.Controllers +{ + public class AccountController : Controller + { + public IActionResult Login(string returnUrl = "/") + { + return new ChallengeResult("Auth0", new AuthenticationProperties() {RedirectUri = returnUrl}); + } + + [Authorize] + public async Task Logout() + { + await HttpContext.Authentication.SignOutAsync("Auth0", new AuthenticationProperties + { + // Indicate here where Auth0 should redirect the user after a logout. + // Note that the resulting absolute Uri must be whitelisted in the + // **Allowed Logout URLs** settings for the client. + RedirectUri = Url.Action("Index", "Home") + }); + await HttpContext.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + } + + public IActionResult AccessDenied() + { + return View(); + } + } +} \ No newline at end of file diff --git a/Samples/oidc-hs256/Controllers/HomeController.cs b/Samples/oidc-hs256/Controllers/HomeController.cs new file mode 100644 index 0000000..698e627 --- /dev/null +++ b/Samples/oidc-hs256/Controllers/HomeController.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace AspNetCoreOidcSample.Controllers +{ + public class HomeController : Controller + { + public IActionResult Index() + { + return View(); + } + + public IActionResult Error() + { + return View(); + } + } +} diff --git a/Samples/oidc-hs256/Dockerfile b/Samples/oidc-hs256/Dockerfile new file mode 100644 index 0000000..5ea5045 --- /dev/null +++ b/Samples/oidc-hs256/Dockerfile @@ -0,0 +1,11 @@ +FROM microsoft/aspnet:1.0.0-rc1-update1 + +RUN printf "deb http://ftp.us.debian.org/debian jessie main\n" >> /etc/apt/sources.list +RUN apt-get -qq update && apt-get install -qqy sqlite3 libsqlite3-dev && rm -rf /var/lib/apt/lists/* + +COPY . /app +WORKDIR /app +RUN ["dnu", "restore"] + +EXPOSE 5000/tcp +ENTRYPOINT ["dnx", "-p", "project.json", "Microsoft.AspNet.Server.Kestrel", "--server.urls", "http://0.0.0.0:5000"] diff --git a/Samples/oidc-hs256/Program.cs b/Samples/oidc-hs256/Program.cs new file mode 100644 index 0000000..64aeca3 --- /dev/null +++ b/Samples/oidc-hs256/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; + +namespace AspNetCoreOidcSample +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/Samples/oidc-hs256/Properties/launchSettings.json b/Samples/oidc-hs256/Properties/launchSettings.json new file mode 100644 index 0000000..e610887 --- /dev/null +++ b/Samples/oidc-hs256/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:55462/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "AspNetCoreOidcSample": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Samples/oidc-hs256/README.md b/Samples/oidc-hs256/README.md new file mode 100644 index 0000000..2f0e846 --- /dev/null +++ b/Samples/oidc-hs256/README.md @@ -0,0 +1,148 @@ +# ASP.NET Core OIDC Sample - HS256 + +This sample demonstrates how you can configure the standard OIDC middleware to authenticate users of an ASP.NET Core MVC application using Auth0 **when using HS256 signed tokens**. + +For more information on how to use Auth0 with ASP.NET Core, please look at the [ASP.NET Core Quickstart](https://auth0.com/docs/quickstart/webapp/aspnet-core) + +## 1. Configure your Auth0 application + +Go to the [Auth0 Dashboard](https://manage.auth0.com) and ensure that you: + +* Add the URL `http://localhost:5000/signin-auth0` to your list of callback URLs +* Configure your application to sign JWT using HS256 (you find this under Settings > Show Advanced Settings > OAuth > JsonWebToken Signature Algorithm) + +## 2. Add the cookie and OIDC NuGet packages + +``` +Install-Package Microsoft.AspNetCore.Authentication.Cookies +Install-Package Microsoft.AspNetCore.Authentication.OpenIdConnect +``` + +## 3. Configure Authentication Services + +In the `ConfigureServices` of your `Startup` class, ensure that you add the authentication services: + +``` +public void ConfigureServices(IServiceCollection services) +{ + // Add authentication services + services.AddAuthentication( + options => options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); + + // Add framework services. + services.AddMvc(); + + // Add functionality to inject IOptions + services.AddOptions(); + + // Add the Auth0 Settings object so it can be injected + services.Configure(Configuration.GetSection("Auth0")); +} +``` + +## 4. Configure the cookie and OIDC middleware + +In the `Configure` method of your `Startup` class, prepare the signature validation key, register the Cookie and OIDC middleware: + +``` +// Add the cookie middleware +app.UseCookieAuthentication(new CookieAuthenticationOptions +{ + AutomaticAuthenticate = true, + AutomaticChallenge = true +}); + +// Get the client secret used for signing the tokens +var keyAsBytes = Encoding.UTF8.GetBytes(auth0Settings.Value.ClientSecret); +var issuerSigningKey = new SymmetricSecurityKey(keyAsBytes); + +// Add the OIDC middleware +app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions("Auth0") +{ + // Set the authority to your Auth0 domain + Authority = $"https://{auth0Settings.Value.Domain}", + + // Configure the Auth0 Client ID and Client Secret + ClientId = auth0Settings.Value.ClientId, + ClientSecret = auth0Settings.Value.ClientSecret, + + // Do not automatically authenticate and challenge + AutomaticAuthenticate = false, + AutomaticChallenge = false, + + // Set response type to code + ResponseType = "code", + + // Set the callback path, so Auth0 will call back to http://localhost:5000/signin-auth0 + // Also ensure that you have added the URL as an Allowed Callback URL in your Auth0 dashboard + CallbackPath = new PathString("/signin-auth0"), + + // Configure the Claims Issuer to be Auth0 + ClaimsIssuer = "Auth0", + + // The UserInfo endpoint does not really return any extra claims which were not returned in the original auth response, so + // we can save ourselves from making an extra request + GetClaimsFromUserInfoEndpoint = false, + + // manually setup the signature validation key + TokenValidationParameters = new TokenValidationParameters + { + IssuerSigningKey = issuerSigningKey + } +}); +``` + +## 5. Handle the login and logout routes + +The cookie middleware will redirect users to the `account/login` and `account/logout` paths respectively to log users in or out. We need to add an `AccountController` class with actions to handle these routes: + +``` +public class AccountController : Controller +{ + public IActionResult Login(string returnUrl = "/") + { + return new ChallengeResult("Auth0", new AuthenticationProperties() {RedirectUri = returnUrl}); + } + + [Authorize] + public async Task Logout() + { + await HttpContext.Authentication.SignOutAsync("Auth0", new AuthenticationProperties + { + // Indicate here where Auth0 should redirect the user after a logout. + // Note that the resulting absolute Uri must be whitelisted in the + // **Allowed Logout URLs** settings for the client. + RedirectUri = Url.Action("Index", "Home") + }); + await HttpContext.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + } +} +``` + +# Running the application + +To run this sample you can fork and clone this repo. + +Be sure to update the appsettings.json with your Auth0 settings: + + { + "Auth0": { + "domain": "Your Auth0 domain", + "clientId": "Your Auth0 Client Id", + "clientSecret": "Your Auth0 Client Secret" + } + } + +Then, restore the NuGet and Bower packages and run the application: + +``` +# Install the dependencies +bower install +dotnet restore + +# Run +dotnet run +``` + +You can shut down the web server manually by pressing Ctrl-C. + diff --git a/Samples/oidc-hs256/Startup.cs b/Samples/oidc-hs256/Startup.cs new file mode 100644 index 0000000..083b53f --- /dev/null +++ b/Samples/oidc-hs256/Startup.cs @@ -0,0 +1,153 @@ +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using System; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.IdentityModel.Tokens; + +namespace AspNetCoreOidcSample +{ + public class Startup + { + public Startup(IHostingEnvironment env) + { + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) + .AddEnvironmentVariables(); + Configuration = builder.Build(); + } + + public IConfigurationRoot Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + // Add authentication services + services.AddAuthentication( + options => options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme); + + // Add framework services. + services.AddMvc(); + + // Add functionality to inject IOptions + services.AddOptions(); + + // Add the Auth0 Settings object so it can be injected + services.Configure(Configuration.GetSection("Auth0")); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IOptions auth0Settings) + { + loggerFactory.AddConsole(Configuration.GetSection("Logging")); + loggerFactory.AddDebug(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + app.UseBrowserLink(); + } + else + { + app.UseExceptionHandler("/Home/Error"); + } + + app.UseStaticFiles(); + + // Add the cookie middleware + app.UseCookieAuthentication(new CookieAuthenticationOptions + { + AutomaticAuthenticate = true, + AutomaticChallenge = true + }); + + // Get the client secret used for signing the tokens + var keyAsBytes = Encoding.UTF8.GetBytes(auth0Settings.Value.ClientSecret); + + // if using non-base64 encoded key, just use: + //var keyAsBase64 = auth0Settings.Value.ClientSecret.Replace('_', '/').Replace('-', '+'); + //var keyAsBytes = Convert.FromBase64String(keyAsBase64); + + var issuerSigningKey = new SymmetricSecurityKey(keyAsBytes); + + // Add the OIDC middleware + app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions("Auth0") + { + // Set the authority to your Auth0 domain + Authority = $"https://{auth0Settings.Value.Domain}", + + // Configure the Auth0 Client ID and Client Secret + ClientId = auth0Settings.Value.ClientId, + ClientSecret = auth0Settings.Value.ClientSecret, + + // Do not automatically authenticate and challenge + AutomaticAuthenticate = false, + AutomaticChallenge = false, + + // Set response type to code + ResponseType = "code", + + // Set the callback path, so Auth0 will call back to http://localhost:5000/signin-auth0 + // Also ensure that you have added the URL as an Allowed Callback URL in your Auth0 dashboard + CallbackPath = new PathString("/signin-auth0"), + + // Configure the Claims Issuer to be Auth0 + ClaimsIssuer = "Auth0", + + // The UserInfo endpoint does not really return any extra claims which were not returned in the original auth response, so + // we can save ourselves from making an extra request + GetClaimsFromUserInfoEndpoint = false, + + Events = new OpenIdConnectEvents + { + // handle the logout redirection + OnRedirectToIdentityProviderForSignOut = (context) => + { + var logoutUri = $"https://{auth0Settings.Value.Domain}/v2/logout?client_id={auth0Settings.Value.ClientId}"; + + var postLogoutUri = context.Properties.RedirectUri; + if (!string.IsNullOrEmpty(postLogoutUri)) + { + if (postLogoutUri.StartsWith("/")) + { + // transform to absolute + var request = context.Request; + postLogoutUri = request.Scheme + "://" + request.Host + request.PathBase + postLogoutUri; + } + logoutUri += $"&returnTo={ Uri.EscapeDataString(postLogoutUri)}"; + } + + context.Response.Redirect(logoutUri); + context.HandleResponse(); + + return Task.CompletedTask; + } + }, + + // manually setup the signature validation key + TokenValidationParameters = new TokenValidationParameters + { + IssuerSigningKey = issuerSigningKey + } + }); + + app.UseMvc(routes => + { + routes.MapRoute( + name: "default", + template: "{controller=Home}/{action=Index}/{id?}"); + }); + } + } +} + diff --git a/Samples/oidc-hs256/Views/Account/AccessDenied.cshtml b/Samples/oidc-hs256/Views/Account/AccessDenied.cshtml new file mode 100644 index 0000000..9a6f8d5 --- /dev/null +++ b/Samples/oidc-hs256/Views/Account/AccessDenied.cshtml @@ -0,0 +1,8 @@ +@{ + ViewData["Title"] = "Access Denied"; +} + +
+

Access Denied.

+

You do not have access to this resource.

+
diff --git a/Samples/oidc-hs256/Views/Home/Index.cshtml b/Samples/oidc-hs256/Views/Home/Index.cshtml new file mode 100644 index 0000000..957b8c1 --- /dev/null +++ b/Samples/oidc-hs256/Views/Home/Index.cshtml @@ -0,0 +1,109 @@ +@{ + ViewData["Title"] = "Home Page"; +} + + + + diff --git a/Samples/oidc-hs256/Views/Shared/Error.cshtml b/Samples/oidc-hs256/Views/Shared/Error.cshtml new file mode 100644 index 0000000..229c2de --- /dev/null +++ b/Samples/oidc-hs256/Views/Shared/Error.cshtml @@ -0,0 +1,14 @@ +@{ + ViewData["Title"] = "Error"; +} + +

Error.

+

An error occurred while processing your request.

+ +

Development Mode

+

+ Swapping to Development environment will display more detailed information about the error that occurred. +

+

+ Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. +

diff --git a/Samples/oidc-hs256/Views/Shared/_Layout.cshtml b/Samples/oidc-hs256/Views/Shared/_Layout.cshtml new file mode 100644 index 0000000..c15cb9b --- /dev/null +++ b/Samples/oidc-hs256/Views/Shared/_Layout.cshtml @@ -0,0 +1,75 @@ + + + + + + @ViewData["Title"] - AspNetCoreOidcSample + + + + + + + + + + + + +
+ @RenderBody() +
+
+

© 2016 - AspNetCoreOidcSample

+
+
+ + + + + + + + + + + + + @RenderSection("scripts", required: false) + + diff --git a/Samples/oidc-hs256/Views/_ViewImports.cshtml b/Samples/oidc-hs256/Views/_ViewImports.cshtml new file mode 100644 index 0000000..5e3fc8d --- /dev/null +++ b/Samples/oidc-hs256/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using AspNetCoreOidcSample +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/Samples/oidc-hs256/Views/_ViewStart.cshtml b/Samples/oidc-hs256/Views/_ViewStart.cshtml new file mode 100644 index 0000000..820a2f6 --- /dev/null +++ b/Samples/oidc-hs256/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +} diff --git a/Samples/oidc-hs256/appsettings.json b/Samples/oidc-hs256/appsettings.json new file mode 100644 index 0000000..b4d0823 --- /dev/null +++ b/Samples/oidc-hs256/appsettings.json @@ -0,0 +1,15 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + }, + "auth0": { + "domain": "{DOMAIN}", + "clientId": "{CLIENT_ID}", + "clientSecret": "{CLIENT_SECRET}" + } +} diff --git a/Samples/oidc-hs256/bower.json b/Samples/oidc-hs256/bower.json new file mode 100644 index 0000000..272b464 --- /dev/null +++ b/Samples/oidc-hs256/bower.json @@ -0,0 +1,10 @@ +{ + "name": "aspnetcoreoidcsample", + "private": true, + "dependencies": { + "bootstrap": "3.3.6", + "jquery": "2.2.3", + "jquery-validation": "1.15.0", + "jquery-validation-unobtrusive": "3.2.6" + } +} diff --git a/Samples/oidc-hs256/gulpfile.js b/Samples/oidc-hs256/gulpfile.js new file mode 100644 index 0000000..faf2955 --- /dev/null +++ b/Samples/oidc-hs256/gulpfile.js @@ -0,0 +1,45 @@ +/// +"use strict"; + +var gulp = require("gulp"), + rimraf = require("rimraf"), + concat = require("gulp-concat"), + cssmin = require("gulp-cssmin"), + uglify = require("gulp-uglify"); + +var webroot = "./wwwroot/"; + +var paths = { + js: webroot + "js/**/*.js", + minJs: webroot + "js/**/*.min.js", + css: webroot + "css/**/*.css", + minCss: webroot + "css/**/*.min.css", + concatJsDest: webroot + "js/site.min.js", + concatCssDest: webroot + "css/site.min.css" +}; + +gulp.task("clean:js", function (cb) { + rimraf(paths.concatJsDest, cb); +}); + +gulp.task("clean:css", function (cb) { + rimraf(paths.concatCssDest, cb); +}); + +gulp.task("clean", ["clean:js", "clean:css"]); + +gulp.task("min:js", function () { + return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) + .pipe(concat(paths.concatJsDest)) + .pipe(uglify()) + .pipe(gulp.dest(".")); +}); + +gulp.task("min:css", function () { + return gulp.src([paths.css, "!" + paths.minCss]) + .pipe(concat(paths.concatCssDest)) + .pipe(cssmin()) + .pipe(gulp.dest(".")); +}); + +gulp.task("min", ["min:js", "min:css"]); diff --git a/Samples/oidc-hs256/oidc-hs256.csproj b/Samples/oidc-hs256/oidc-hs256.csproj new file mode 100644 index 0000000..2b76463 --- /dev/null +++ b/Samples/oidc-hs256/oidc-hs256.csproj @@ -0,0 +1,48 @@ + + + + netcoreapp1.1 + true + AspNetCoreOidcSample + Exe + oidc-hs256 + 1.0.4 + $(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+win8 + AspNetCoreOidcSample + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/oidc-hs256/oidc-hs256.sln b/Samples/oidc-hs256/oidc-hs256.sln new file mode 100644 index 0000000..220b489 --- /dev/null +++ b/Samples/oidc-hs256/oidc-hs256.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.7 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "oidc-hs256", "oidc-hs256.csproj", "{DF80D9E3-96BA-4B6F-B927-5FD741F54292}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF80D9E3-96BA-4B6F-B927-5FD741F54292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF80D9E3-96BA-4B6F-B927-5FD741F54292}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF80D9E3-96BA-4B6F-B927-5FD741F54292}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF80D9E3-96BA-4B6F-B927-5FD741F54292}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/oidc-hs256/package.json b/Samples/oidc-hs256/package.json new file mode 100644 index 0000000..154facd --- /dev/null +++ b/Samples/oidc-hs256/package.json @@ -0,0 +1,12 @@ +{ + "name": "aspnetcoreoidcsample", + "version": "0.0.0", + "private": true, + "devDependencies": { + "gulp": "3.9.1", + "gulp-concat": "2.6.0", + "gulp-cssmin": "0.1.7", + "gulp-uglify": "1.5.3", + "rimraf": "2.5.2" + } +} diff --git a/Samples/oidc-hs256/runtimeconfig.template.json b/Samples/oidc-hs256/runtimeconfig.template.json new file mode 100644 index 0000000..3dc8eba --- /dev/null +++ b/Samples/oidc-hs256/runtimeconfig.template.json @@ -0,0 +1,3 @@ +{ + "gcServer": true +} \ No newline at end of file diff --git a/Samples/oidc-hs256/web.config b/Samples/oidc-hs256/web.config new file mode 100644 index 0000000..a8d6672 --- /dev/null +++ b/Samples/oidc-hs256/web.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/Samples/oidc-hs256/wwwroot/css/site.css b/Samples/oidc-hs256/wwwroot/css/site.css new file mode 100644 index 0000000..a32e39a --- /dev/null +++ b/Samples/oidc-hs256/wwwroot/css/site.css @@ -0,0 +1,31 @@ +body { + padding-top: 50px; + padding-bottom: 20px; +} + +/* Wrapping element */ +/* Set some basic padding to keep content from hitting the edges */ +.body-content { + padding-left: 15px; + padding-right: 15px; +} + +/* Set widths on the form inputs since otherwise they're 100% wide */ +input, +select, +textarea { + max-width: 280px; +} + +/* Carousel */ +.carousel-caption p { + font-size: 20px; + line-height: 1.4; +} +/* Hide/rearrange for smaller screens */ +@media screen and (max-width: 767px) { + /* Hide captions */ + .carousel-caption { + display: none + } +} diff --git a/Samples/oidc-hs256/wwwroot/css/site.min.css b/Samples/oidc-hs256/wwwroot/css/site.min.css new file mode 100644 index 0000000..af11915 --- /dev/null +++ b/Samples/oidc-hs256/wwwroot/css/site.min.css @@ -0,0 +1 @@ +body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}@media screen and (max-width:767px){.carousel-caption{display:none}} diff --git a/Samples/oidc-hs256/wwwroot/favicon.ico b/Samples/oidc-hs256/wwwroot/favicon.ico new file mode 100644 index 0000000..a3a7999 Binary files /dev/null and b/Samples/oidc-hs256/wwwroot/favicon.ico differ diff --git a/Samples/oidc-hs256/wwwroot/images/banner1.svg b/Samples/oidc-hs256/wwwroot/images/banner1.svg new file mode 100644 index 0000000..1ab32b6 --- /dev/null +++ b/Samples/oidc-hs256/wwwroot/images/banner1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Samples/oidc-hs256/wwwroot/images/banner2.svg b/Samples/oidc-hs256/wwwroot/images/banner2.svg new file mode 100644 index 0000000..9679c60 --- /dev/null +++ b/Samples/oidc-hs256/wwwroot/images/banner2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Samples/oidc-hs256/wwwroot/images/banner3.svg b/Samples/oidc-hs256/wwwroot/images/banner3.svg new file mode 100644 index 0000000..9be2c25 --- /dev/null +++ b/Samples/oidc-hs256/wwwroot/images/banner3.svg @@ -0,0 +1 @@ +banner3b \ No newline at end of file diff --git a/Samples/oidc-hs256/wwwroot/images/banner4.svg b/Samples/oidc-hs256/wwwroot/images/banner4.svg new file mode 100644 index 0000000..38b3d7c --- /dev/null +++ b/Samples/oidc-hs256/wwwroot/images/banner4.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Samples/oidc-hs256/wwwroot/js/site.js b/Samples/oidc-hs256/wwwroot/js/site.js new file mode 100644 index 0000000..e069226 --- /dev/null +++ b/Samples/oidc-hs256/wwwroot/js/site.js @@ -0,0 +1 @@ +// Write your Javascript code. diff --git a/Samples/oidc-hs256/wwwroot/js/site.min.js b/Samples/oidc-hs256/wwwroot/js/site.min.js new file mode 100644 index 0000000..e69de29