Skip to content

Tutorial

Daniel Mihaita edited this page Sep 29, 2017 · 4 revisions

This is where you start if you are at the beginning of your journey in the NET Core world. More specific, this is a tutorial for setting up the auth-sso application locally.

PS: you're current environment should be on Windows 8, 8.1 or 10 for this tutorial :)

Environment setup

Install MS Visual Studio Community 2017

Install .NET Core SDK & Tools

  • Follow the instructions here
  • Download current NET Core
  • Go here
  • Download .NET Core 1.1 SDK - Installer for Windows x64 or x86

You need mariaDB or mysql installed on your environment

If you haven't worked with these databases before, I recommend that you should start with XAMPP.

Git

If you haven't worked with Git, you need:

  • Shell:Git for windows
  • GUI: SourceTree So, consider the fact that you will have two "git" apps installed. Work only from one (command line or GUI) otherwise it will start to be very complicated.

Personally, I work with:

  • Command line (checkout, branch, status, pull) + cmder instead of windows command prompt
  • MS Visual Studio (add, commit, push, view file history, conflict editor)

If you are new to git, here are some concepts & tutorials:

Local branch

  • Create a folder for civictechro organization (recommended path: [drive letter]:\projects\civictechro)
  • Open command prompt/cmder
  • Navigate to [drive letter]:\projects\civictechro
  • Now we are going to grab the sources from github: git clone https://github.com/civictechroauth-sso.git
  • Let's move inside the newly created clone from github repository: cd auth-sso
  • We're going to create a local branch called {username}-tutorial-env. For testing purposes, please replace {username} with your github username: git checkout -b {alexchiraples}-tutorial-env
  • When you run git checkout -b [branch name] git automatically moves you from master branch to your newly created branch. When you're finished with your current set of developments you'll move to a new branch and delete this one :). I'll give some examples later in this tutorial.

You're all set with configuring the environment 👍

If you don't have the latest version:

  • Go back on master: git checkout master
  • Get latest version: git pull
  • Go to your branch, in this example for me it is: git checkout alexchiraples-tutorial-env
  • Update current branch with master: git merge master
  • If there are conflicts, open Visual Studio and solve the conflicts

All done with the code 📦. You should be able to open the solution in Visual Studio. Before starting the applications we still need to configure and create the database

Database

Create a database called sso.

Nota : Pe o instanta de MariaDB (10.1.23) am fost nevoi sa creez baza de date cu urmatoarea comanda : create database sso default CHARACTER set utf8 default COLLATE utf8_general_ci; pentru a evita eroarea "Specified key was too long; max key length is 767 bytes" la initializarea bazei de date.

XAMPP

  • open XAMPP
  • start MySQL. You need to do this every time you want to run the application
  • start 'Apache'
  • open http://localhost/phpmyadmin
  • create a new database called sso with no extra configuration
  • click sso database, go to Privileges
  • create a new user & pass associated to local (localhost). ex: user=ssouser, password=ssouserpass
  • give permissions for this user to access only the sso database

Configuration files

  • copy [drive letter]:\projects\civictechro\auth-sso\src\GovITHub.Auth.Identity\connectionstrings.Sample.json to [drive letter]:\projects\civictechro\auth-sso\src\GovITHub.Auth.Identity\connectionstrings.json
  • update the file connectionstrings.json

Install

By now, you have created your environment and you are ready to start the application

General

  • open command prompt
  • go to [drive letter]:\projects\civictechro\auth-sso
  • update submodule dependencies: git submodule update --init --recursive
  • restore all dotnet packages: dotnet restore

Run Identity server

cd src\GovITHub.Auth.Identity
npm install
bower install
dotnet run

If no error displayed, after you see "Application started. Press Ctrl+C to shut down." you can navigate to http://localhost:5000 to access IdentityServer.

Start development

  • open command prompt and navigate to your repository: cd path...
  • grab latest verion git pull
  • create a new local branch git checkout -b ...
  • restore nuget packages in IdentityServer folder: dotnet restore
  • run the application: dotnet run

dotnet run = compile + run application

References:

  1. https://github.com/civictechro/auth-sso.git - auth-sso home project
  2. https://www.microsoft.com/net/download/core - NET Core SDK & Tooling
  3. http://juristr.com/blog/2013/04/git-explained/ - Git explained for beginners
  4. https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db - tutorial for entity framework (ef) in .net core
  5. https://www.npmjs.com/ - npm is the package manager for javascript