Monday, November 7, 2016

.NET Core Authentication: a taste of what's to come

I've been very busy getting my hands dirty with .NET Core.  It's pretty awesome stuff

The latest endeavor has been to get OpenID Connect to work in 2 directions with ASP.NET Core:

1. Web API server authenticates via JWT thru a Xamarin Android app
2. Regular browseable web pages authenticate via OAuth2/OpenID Connect cookie (I don't fully understand it either but it works!)

Scenario 1 is important because mobile and maybe desktop apps can use this standardized JWT format for API calls in lieu of the likely-proprietary cookie format

Scenario 2 is important because for your web users they want SSO like behavior, which cookies plus OpenID connect provide (i.e. the "sign in with google" button we're all accustomed to seeing)

Importantly, both scenarios are working with Google Sign In.  Thus, in theory, no new account registration required anywhere to be authenticated - presuming you have a Google login of course ;)

I plan to provide example code of how to do all this & understand most of it.  It took a lot of digging around to make it all work!

Tuesday, May 17, 2016

Debian + ASP.NET Core 1.0 RC2 + AngularJS 2

This is a short blurb about my experience implementing the great examples provided at within an open-source Debian linux environment and using slightly newer tooling.

Since he (she? they?) has gone into excellent depth, I'll only cover what I did differently to get it to work in a non-Windows environment (spoiler alert: not much!)

ASP.NET Core 1.0 RC2

Presumably you installed ASP.NET Core 1.0 RC2 already.  If not, head over to  Having only ever built from source, I can't comment on the prebuilt binaries.  My bet is they will work well.


To create ASP.NET boilerplate code, we use Yeoman (installed via npm).  Type:

yo aspnet

Then Choose "Web Application" because conveniently enough, MVC now is Web API with ASP.NET Core!

Check this page for installation tips:

Visual Studio Code

While not strictly necessary, I found Visual Studio Code to be very robust and it sped me through many otherwise slow, trudging tasks.  This includes:

  • C# syntax error highlighting
  • assist with "using" statements
  • Integrated debugging - although I lucked out and didn't need it, it does work very well and having that on tap has a value which cannot be overstated

Building Visual Studio Code ... from code

Most folks will install direct from a download, but if you're like me and want to build vscode from source, be advised - I found no "install" mechanism when building Visual Studio code.

For convenience, after building Visual Studio Code I made a $PATH discoverable symlink called "vscode" to easily start it anywhere.  I suggest you do the same

.vscode folder & tasks.json

Visual Studio code creates a .vscode folder and assists you in creating two files:
  • launch.json - among other things, this feeds the debugger for what configurations you'd like to launch & debug
  • tasks.json - when using vscode's integrated build feature (ctrl-shift-B on non Macs) it reaches out to this file to determine what to do.
I ran into an issue where I wanted typescript files to auto compile, which apparently is also a tasks.json configuration.  So two different behaviors for tasks.json, but everywhere I read had super confusing examples for how to do that.  My conclusion: I don't fully understand tasks.json and assume I must perform typescript compilation manually.

To that end, I use "tsc" (install via npm).  


With my weak JavaScript skills (of which I am not ashamed) it took some fiddling to get paths.npmLibs right.  I deviated from the example as the new boilerplate code is a smidge different.  Here's my paths code:

 For you non-weak JavaScript programmers, I'm sure you've already moved past this one

Don't forget, Visual Studio isn't here to help you with gulp tasks, so you'll have to run them manually (you'll want to run gulp copy-deps and gulp min) after you've done a proper npm install.  Remember, a proper npm install won't work until your package.json is sorted out.


Most of my difficulties in bringing up functioning code boiled down to getting package.json right.  Visual Studio Code provides a lot of help, but still fiddling was required.  Here's what I came up with:


With all that in place, we get results identical to what is seen on the talkingdotnet site (the initially mentioned article) - but now running on 100% open source and free software!