Authentication When Communicating with External Services

You may want to send HTTP requests to external services from workflows. The service you communicate with may require authentication and that is what this feature can help you with.

If you need the authentication feature you can create a new dll project separate from the Origam solution and implement your own IClientAuthenticationProvider. This Interface is defined here and is a part of the Origam.Service.Core nuget package. There are two methods in the interface:

bool TryAuthenticate(string url, Hashtable headers)

Should return false if your implementation cannot authenticate the request to the URL. If the request can be authenticated the headers should be modified accordingly.

void Configure(IConfiguration configuration)

Receives IConfiguration parsed from the appsettings. There are no constraints on what should be read from the configuration. Write what you need to the appsettings.json and read it here.

The configuration section for the class implementing this interface should have the same name as the class.

After you implement your authenticator you have to register it in the appsettings.json of the Origam Server. This is done in the ExtensionDlls array. The array should contain full paths to the dlls you wish to include separated by ,. Here is an example of what you may add to your appsettings.json:

{
  "ExtensionDlls": ["C:\\Repos\\SomeAuthenticatorImplementation\\bin\\Release\\net6.0\\SomeAuthenticatorImplementation.dll"],
}

Resource Owner Password Authentication Provider

Origam already includes one IClientAuthenticationProvider implementation called the ResourceOwnerPasswordAuthenticationProvider. This provider can authenticate requests using the OAuth Resource Owner Password Flow. Since it is already included in Origam you don’t have to add it to the ExtensionDlls in the configuration. You only have to add the specific provider configuration to the appsettings.json. Something like this:

"ResourceOwnerPasswordAuthenticationProviderConfig": {
	"UrlsToBeAuthenticated":["http://localhost:8080"],
	"AuthServerUrl": "http://localhost:8080",
	"ClientId": "clientId",
	"ClientSecret": "serverSecret",
	"UserName": "UserNameToUseInTheExternalService",
	"Password": "PasswordToUseInTheExternalService
}