ADFS Configuration Manual
Setting up AD FS to run OIDC for MOPS 4.0
AD FS supports OAuth2 and thereby OpenID Connect (OIDC) out of the box. This standard of token-based authentication is required for the entire MOPS 4.0 system, client application will make requests to the Identity Provider to authenticate clients, their access to MOPS 4.0 APIs and authorize users in the MOPS 4.0 web-application.
Prerequisites
This guide is for configuring AD FS for MOPS 4.0 (web-client application) and requires that the following is already setup & available:
- Windows Server 2019 machine (or later) with AD FS installed.
- Certificate for signing tokens.
Setting Federation Service Identifier
In the OpenID Connect standard there is an exposed endpoint to retrieve all service endpoints, allowed authentication methods, response types, supported claims, allowed scopes and so on. This endpoint must be accessible by MOPS 4.0, and to make sure it can be accessed, Federation Service Identifier must be set correctly. How to make sure configured right:
- Open
Server Manageron the computer that is runningAD FS, on the top-right menu chooseTools>AD FS Management.

-
In
AD FS, in the menu to the left, right-click onAD FSand selectEdit Federation Service Properties... -
Make sure the field
Federation Service identifierends with/adfsand not/adfs/services/trust.

Adding an Application Group
- In
AD FS, in the menu to the left, right-click onApplication Groups>Add Application Group....

Add Application Group Wizardwill open, in theNamefield typeMOPS4.0and select the TemplateNative application accessing a web APImarked in the screenshot below. This will add steps in the menu to the left.

- In
Native Application, Change the generatedClient IdentifiertoMOPSand add the following url:s by entering them inRedirect URIand clickingAdd:
https://<your_mops4_installation>/callback
Shown as http://localhost/callback in the screenshot below.
The Name field can be left as-is.

- In
Configure Web API, addMOPSasIdentifier.
The Name field can be left as-is.

- Select an
Access Control Policy-template, selectingPermit everyonewill allow everyone to access this Application Group.

- In
Configure Application Permissions,Client application-box should already containMOPS4.0 - Native application.
In the box below, select the scopes openid, email and profile.

- In the final step, verify that provided configuration is correct.
Modifying claims to work with MOPS 4.0
The OpenID Connect standard contains all claims needed by MOPS 4.0, however AD FS does some things a bit different. In an access token generated by AD FS, the standard client_id is called appid, this means an additional claim called client_id must be added and mapped to use the value from appid. Following are the steps to do so:
- In
AD FS, expandServicesand selectClaim Descriptions.

- Add a new claim by either right-clicking
Claim Descriptions>Add Claim Description...on the left-hand menu orAdd Claim Description...inActionsmenu on the right.
- Fill in the form as shown below, where
Display Namewill be used for mapping andShort Nameis what the claim will be called in an access token.
Remember to check both options for publishing this claim description!

- To map the created
client_idclaim to use the value fromappid, clickApplication Groups>MOPS4.0>MOPS4.0 - Web API>Issuance Transform Rules, the window will look like this:

- Click
Add Rule. A new window will appear, select Claim rule templateTransform an Incoming Claim.

- Fill in the for as specified below, it will map the incoming
Oauth Client Id(appidclaim) to the newly createdOIDC Client ID(client_idclaim that will be shown in access tokens). Then selectPass through all claim valuesand click finish.

Additional claims
One more claim mapping rule is required, there are a couple of claims for user information that needs to be exposed in every access token. These are LDAP-attributes that have their values mapped straight through so it is a much simpler process, no new claim descriptions are required:
- In
AD FS, clickApplication Groups>MOPS4.0>MOPS4.0 - Web API>Issuance Transform Rulesand clickAdd Rule. In the new window select the Claim rule templateSend LDAP Attributes as Claims.

- In the next window, fill in the form like this:

Note that E-mail-Addresses are mapped twice, once to E-mail Address, which is the claim
Name IDwhich is thesubclaim in an access token. Thesubclaim is used as a unique identifier for users in MOPS 4.0 and it is important that it’s present in every access token.)
If MOPS 4.0 is not running on the same domain as AD FS
In a likely scenario, MOPS 4.0 will need to make a Cross-Origin Resource Sharing (CORS) request when the application is trying to reach AD FS installed on a different domain than the MOPS 4.0 installation. In order for this to work, CORS response headers for AD FS must be enabled and a trusted origin must be added, this is done in two simple steps:
-
On the machine where AD FS is installed, open an elevated Windows Powershell window (run it as Administrator), and run the following command:
Set-AdfsResponseHeaders -EnableCORS $true. -
Run a second command with the allowed origin:
Set-AdfsResponseHeaders -CORSTrustedOrigins https://<your_mops4_installation>
To add multiple trusted CORS origins simply divide them with a ‘,’ example:
Set-AdfsResponseHeaders -CORSTrustedOrigins https://<your_mops4_installation>,https://<other_trusted_origin>
To check if CORS is configured correct run Get-AdfsResponseHeaders, this command will show the properties CORSEnabled, which should be True and the CORSTrustedOrigins that has been set.
Condition Monitoring System (CMS)
If CMS was installed with MOPS 4.0, it’s services will also need to be authenticated. Since these services are not interactive users in the UI of MOPS 4.0 they will need to setup to use the client_credentials OIDC flow. In ADFS an additional client must be created in the same application group as the one used for MOPS 4.0.
- Click on
Application Groupsto the left and then selectmops-test. Click onAdd Application...

- Select
Server Application

- Enter a name in the
Client Identifier-field, this could beMOPS4.0-CMS. In theRedirect URI-field enter the same URL as main client,https://<your_mops4_installation>/callback

- Check
Generated a shared secretand click onCopy to clipboard. This value should be sent to the person configuring CMS for MOPS 4.0.
This value will only be visible in this window and only once
