Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SkillsFundingAgency/das-apim-developer-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

300 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⛔Never push sensitive information such as client id's, secrets or keys into repositories including in the README file⛔

APIM Developer API

UK Government logo

Build Status Quality Gate Status License

The APIM developer API is the inner API used to managed subscriptions to externally faced APIs. It also provides a mechanism for formatting the open API definition of the external API, excluding any headers that arent applicable.

How It Works

The APIM Developer API connects to the Azure APIM API to allow the following operations.

  • Get API Products
  • Get Subscriptions
  • Add Subscriptions
  • Renew Subscriptions
  • Delete Subscriptions
  • Create User
  • Update User
  • Authenticate User

Get Products

The API products are retrieved by UserType, currently the available user types are

  • Documentation
  • External
  • Provider
  • Employer

These types are defined against the API when registered in APIM. All APIs have the documentation type defined against them so that they appear in the developer.apprenticeships.gov.uk site

Get Subscriptions

The subscriptions are created in the following format $"{apimUserType}-{internalUserId}-{productName}" where the following is allowed:

apimUserType - Provider, Employer, External

internalUserId - this is the identifier, which is either the UKPRN, EmployerAccountId or External User Id GUID.

productName - The product which the user is subscribing to that is available to them

The subscriptions are then stored in Azure APIM

Create User

This is used to create a user that is able to access the API and is part of the External APIM user type group.

Authenticate User

The authentication process is done using the Azure APIM api, this validates the credentials against what is stored in Azure APIM. No user information is stored in the database for this API

Auditing

There is an internal audit process that runs, this stores a record in the database to record when a subscription has been created or a subscription has been renewed. This is stored in a SQL database.

🚀 Installation

Pre-Requisites

Local running

The APIM developer api uses the standard Apprenticeship Service configuration. All configuration can be found in the das-employer-config repository.

  • appsettings.json file
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "ConfigurationStorageConnectionString": "UseDevelopmentStorage=true;",
  "ConfigNames": "SFA.DAS.Apim.Developer.Api",
  "Environment": "LOCAL",
  "Version": "1.0",
  "APPLICATIONINSIGHTS_CONNECTION_STRING": "",
  "AllowedHosts": "*"
}

You must have the Azure Storage emulator running, and in that a table created called Configuration in that table add the following:

Azure Table Storage config

Row Key: SFA.DAS.Apim.Developer.Api_1.0

Partition Key: LOCAL

Data:

{
  "AzureApimManagement": {
    "ApimUserManagementUrl" : "https://{AZURE-APIM-URL}}",
    "ApimResourceId": "/subscriptions/{SUBSCRIPTION-ID}}/resourceGroups/{RESOURCE-GROUP-NAME}/providers/Microsoft.ApiManagement/service/{APIM-NAME}"
  },
  "ApimDeveloperApi": {
    "ConnectionString": "Data Source=.;Initial Catalog=SFA.DAS.Apim.Developer;Integrated Security=True;Pooling=False;Connect Timeout=30",
    "NumberOfAuthFailuresToLockAccount": 3,
    "AccountLockedDurationMinutes": 10
  },
  "AzureAd": {
    "Identifier": "https://{TENANT-NAME}/{IDENTIFIER}",
    "Tenant": "{TENANT-NAME}"
  }
}

Technologies

  • .NetCore 3.1
  • Azure APIM API access with Azure APIM
  • SQL
  • Azure App Insights
  • Azure Table Storage
  • NUnit
  • Moq
  • FluentAssertions

How It Works

Running

  • Open command prompt and change directory to /src/SFA.DAS.Apim.Developer.Api/
  • Run the web project /src/SFA.DAS.Apim.Developer.Api.csproj

MacOS

ASPNETCORE_ENVIRONMENT=Development dotnet run

Windows cmd

set ASPNETCORE_ENVIRONMENT=Development
dotnet run

Application logs

Application logs are logged to Application Insights and can be viewed using Azure Monitor at https://portal.azure.com

Useful URLs

Products

https://localhost:5001/api/products - Endpoint to get API products are retrieved by UserType

Subscription

https://localhost:5001/api/subscription/{id} - Endpoint to get user's subscription by Id

User

https://localhost:5001/api/users - Endpoint to get all users

https://localhost:5001/api/users/authenticate - Endpoint to validate user credentials

https://localhost:5001/api/users/{id} - Endpoint to create/update user information

🐛 Known Issues

Do not run using IISExpress

License

Licensed under the MIT license

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors