|
1 | 1 | # Introduction |
2 | | -TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project. |
| 2 | +This is the official open source repository for the [Learning Hub](https://learninghub.nhs.uk/) user profile and authentication service. |
| 3 | + |
| 4 | +This repository is used to provide user authentication for the main [Learning Hub repository](https://github.com/TechnologyEnhancedLearning/LearningHub.Nhs.WebUI). |
| 5 | + |
| 6 | +The Learning Hub is the national digital learning platform providing easy access to a wide range of educational resources and support for the health and care workforce and educators. |
| 7 | + |
| 8 | +The Learning Hub is provided and supported the Technology Enhanced Learning platforms team at [NHS England](https://www.england.nhs.uk/). |
3 | 9 |
|
4 | 10 | # Getting Started |
5 | | -TODO: Guide users through getting your code up and running on their own system. In this section you can talk about: |
6 | | -1. Installation process |
7 | | -2. Software dependencies |
8 | | -3. Latest releases |
9 | | -4. API references |
10 | 11 |
|
11 | | -# Build and Test |
12 | | -TODO: Describe and show how to build your code and run the tests. |
| 12 | +## Required installs |
| 13 | +- [Visual Studio Professional 2022](https://visualstudio.microsoft.com/downloads/) or other suitable An IDE that supports the Microsoft Tech Stack |
| 14 | + - Make sure you have the [NPM Task Runner](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.NPMTaskRunner) extension |
| 15 | +- SQL Server 2019 |
| 16 | +- [SQL Server Management Studio 18](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15) |
| 17 | +- [Git](https://git-scm.com/download) |
| 18 | +- [Node](https://nodejs.org/en/download/) install specific/required version using NVM - see below. |
| 19 | +- [SASS](https://www.sass-lang.com/install) for the command line |
| 20 | + - Specifically, follow the "Install Anywhere (Standalone)" guide. Simply download and extract the files somewhere, and point PATH at the dart-sass folder. This should allow you to use the "sass" command. |
| 21 | + - You don't want to install it via Yarn, as those are JavaScript versions that perform significantly worse. |
| 22 | +- [.Net 6.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) |
| 23 | +- [Azure storage emulator](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) |
| 24 | +- [Azure storage explorer](https://azure.microsoft.com/en-gb/features/storage-explorer/#overview) |
| 25 | +- [Node version manager (nvm)](https://github.com/coreybutler/nvm-windows/releases) - use this to install and use Node version 16.13.0 and NPM version 8.1.0 to work with this repository. |
13 | 26 |
|
14 | | -# Contribute |
15 | | -TODO: Explain how other users and developers can contribute to make your code better. |
| 27 | +# Getting the code |
| 28 | + |
| 29 | +Clone the repository from [GitHub](https://github.com/TechnologyEnhancedLearning/LearningHub.Nhs.UserApi): |
| 30 | + |
| 31 | +```bash |
| 32 | +git clone [email protected]:TechnologyEnhancedLearning/LearningHub.Nhs.UserApi.git |
| 33 | +``` |
| 34 | + |
| 35 | +You should now be able to open the solution in your IDE by finding and opening the `LearningHub.Nhs.UserApi.sln` file. |
| 36 | + |
| 37 | +# Build the solution |
| 38 | + |
| 39 | +## Restore the databases |
| 40 | + |
| 41 | +You will need copies of the development databases to run the Learning Hub code. To obtain these, use the details below to become a Learning Hub contributor. |
| 42 | + |
| 43 | +### Restore the ELFH databases |
| 44 | +The ELFH database is currently the user store for Learning Hub learners. |
| 45 | + |
| 46 | +Use SSMS to restore the backup of ELFH DB to your local SQL server (using the DB names in the backup). |
| 47 | + |
| 48 | +### Import the Learning Hub data-tier application |
| 49 | +Use SSMS "Import Data Tier Application" option to restore the LH database. |
| 50 | + |
| 51 | +Simplify the database name to "learninghub" or similar to keep connection strings simple. |
| 52 | + |
| 53 | +### Create a SQL Server Login to use in Connection Strings |
| 54 | +Because the Learning Hub apps will run in IIS, we can't rely on integrated security for the DB connection (because IIS doesn't use your login) a SQL server login will be needed instead. |
| 55 | + |
| 56 | +Ensure that a SQL server login is created that has db owner access to both the ELFH and Learning Hub databases and use the credentials for this login in connection strings. |
| 57 | + |
| 58 | +## Configure IIS hosting |
| 59 | + |
| 60 | +### Create a self-signed certificate |
| 61 | + |
| 62 | +In Windows 10/11 open Powershell with Administrator privileges and enter the following command: |
| 63 | + |
| 64 | +```console |
| 65 | +New-SelfSignedCertificate -DnsName "*.dev.local", "dev.local", "localhost", "*.e-lfh.org.uk", "*.e-lfhtech.org.uk" -CertStoreLocation cert:\LocalMachine\My -FriendlyName "Dev Cert *.dev.local, dev.local, localhost, *.e-lfh.org.uk, *.e-lfhtech.org.uk" -NotAfter (Get-Date).AddYears(15) |
| 66 | +``` |
| 67 | + |
| 68 | +### Trust the certificate |
| 69 | +The new certificate is not part of any chain of trust and is thus not considered trustworthy by any browsers. To change that, copy the certificate to the certificate store for Trusted Root CAs on your machine. In Windows: |
| 70 | + |
| 71 | +1. Open the **Microsoft Management Console** as Administrator (Go to Start, type `mmc` and run as administrator) |
| 72 | +3. From the **File** menu, choose **Add/Remove Snap-In** |
| 73 | +4. Choose **Certificates** in left column and then **Add** |
| 74 | +5. Choose **Computer Account** from the **Select Computer** dialogue and then **Next** |
| 75 | +6. Ensure **Local Computer** is selected and choose **Finish** to close the **Select Computer** dialogue |
| 76 | +7. Choose **OK** to close the **Add or Remove Snap-ins** dialogue |
| 77 | +8. In the left column choose **Certificates (Local Computer) / Personal / Certificates** |
| 78 | +9. Find the newly created cert (in Windows 10 the column **Friendly name** may help) |
| 79 | +10. Select the certificate and hit **Ctrl + C** to copy it to clipboard |
| 80 | +11. In the left column choose **Certificates (Local Computer) / Trusted Root CAs / Certificates** |
| 81 | +12. Hit **Ctrl-V** to paste your certificate to this store |
| 82 | +13. The certificate should appear in the list of **Trusted Root Authorities** and is now considered trustworthy. |
16 | 83 |
|
17 | | -If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files: |
18 | | -- [ASP.NET Core](https://github.com/aspnet/Home) |
19 | | -- [Visual Studio Code](https://github.com/Microsoft/vscode) |
20 | | -- [Chakra Core](https://github.com/Microsoft/ChakraCore) |
| 84 | +### Use in ISS |
| 85 | +Run Internet Information Services (IIS) Manager as Administator (Go to Start and type `iis` and run as administrator). |
| 86 | + |
| 87 | +Create individual websites in IIS Manager. The sites should differ by name but not by port number. |
| 88 | + |
| 89 | +- LearningHubWebClient : "https://lh-web.dev.local/" |
| 90 | +- LearningHubUserAPIUrl : "https://lh-userapi.dev.local/api/" |
| 91 | +- LearningHubApiUrl : "https://lh-api.dev.local/api/" |
| 92 | +- LearningHubAdminUrl : https://lh-admin.dev.local/ |
| 93 | +- LearningHub Auth URL: https://lh-auth.dev.local/ |
| 94 | + |
| 95 | +For each site edit the bindings: |
| 96 | +1. Choose **https** |
| 97 | +2. Check the hostname matches the pattern in the certificate (your cert is only valid for `*.dev.local`) |
| 98 | +3. Choose the new certificate |
| 99 | +4. Choose **OK**. |
| 100 | + |
| 101 | +**NOTE:** IIS is a Windows feature. If it is not already installed it can be switched on using the “Turn Windows features on or off“ dialogue. |
| 102 | + |
| 103 | +### Add to hosts |
| 104 | +Edit your **hosts** file (C:\Windows\System32\drivers\etc\hosts) and add: |
| 105 | +``` |
| 106 | +127.0.0.1 lh-web.dev.local |
| 107 | +127.0.0.1 lh-userapi.dev.local |
| 108 | +127.0.0.1 lh-api.dev.local |
| 109 | +127.0.0.1 lh-admin.dev.local |
| 110 | +127.0.0.1 lh-auth.dev.local |
| 111 | +``` |
| 112 | +## Configure App Settings |
| 113 | + |
| 114 | +Add appsettings.Development.json files to the following projects: |
| 115 | +- LearningHub.Nhs.Auth |
| 116 | +- LearningHub.Nhs.UserApi |
| 117 | + |
| 118 | +### Modify settings |
| 119 | + |
| 120 | +Go through each of the app settings files and ensure connection strings are correct. |
| 121 | + |
| 122 | +Look for references in each of the App Settings files to the URLs of other parts of the service and update them to the URLs specified above |
| 123 | + |
| 124 | +If you are an official contributor (see below) working appsettings.Development.json will be provided by the service team. |
| 125 | + |
| 126 | +## Configure Local IIS profile |
| 127 | + |
| 128 | +Create a Local IIS launch profile for the following projects: |
| 129 | +- LearningHub.Nhs.Auth |
| 130 | +- LearningHub.Nhs.UserApi |
| 131 | + |
| 132 | +1. From the launch drop down choose **Debug Properties** |
| 133 | +2. Create a **New** profile |
| 134 | +3. Choose **IIS** from the drop down and name the profile **IIS Local** |
| 135 | +4. Add the environment name to **Environment variables**: `ASPNETCORE_ENVIRONMENT=Development` |
| 136 | +5. Check **Launch browser** if appropriate (Auth) |
| 137 | +6. Set the **App URL**. Suggested URLs as follows: |
| 138 | + - LearningHub.Nhs.Auth = https://lh-auth.dev.local |
| 139 | + - LearningHub.Nhs.UserAPI = https://lh-userapi.dev.local |
| 140 | +7. Tick the checkbox for **Enable Anonymous Authentication**. |
| 141 | + |
| 142 | +## Add NuGet Package Source |
| 143 | +The Learning Hub solutions have some external custom package dependencies. To obtain access to the package source, use the details below to become a Learning Hub contributor. |
| 144 | + |
| 145 | +Open the solution in Visual Studio and add a new custom Nuget package source: |
| 146 | + |
| 147 | +Go to: **Tools > NuGet Package Manager > Manage NuGet Packages for Solution > Cog** icon |
| 148 | + |
| 149 | +Click the **+** button to create a new package source with name `LHPackages` and source: https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json |
| 150 | + |
| 151 | +## Rebuild and run |
| 152 | + |
| 153 | +1. Rebuild the solution |
| 154 | +2. Set **LearningHub.Nhs.WebUI** as the startup Project |
| 155 | +3. Start debugging. |
| 156 | + |
| 157 | + |
| 158 | +# Contribute |
| 159 | +If you are interested in contributing to the Learning Hub, please contact [[email protected]](mailto:[email protected]) |
0 commit comments