Enabling Delegated Authentication with IPM via module.xml
I am trying to set up a web application with Delegated Authentication via IPM. It is possible to give a specific application Delegated Authentication:
<WebApplicationName="/${namespaceLower}/api"NameSpace="${namespace}"DispatchClass="pkg.isc.genai.rest.Handler"MatchRoles=":%All"AutheEnabled="#{$$$AutheDelegated}"Recurse="1"CookiePath="/${namespaceLower}/"
/>with the AutheEnabled field. This will display the authentication as "delegated" in the SMP Web Applications display, but when one enters the settings page for this application, there is no checkbox for Delegated. This also doesn't seem to function -- ZAUTHENTICATE is never called.
To fix this, I have manually gone to the Authentication/Web Session Options page and enabled Delegated Authentication. With this enabled, ZAUTHENTICATE is called, that checkbox appears, and everything works.
I cannot seem to find a way to automatically enable that in module.xml. Does anyone have any experience with this, or is there another way to do this? (Can you do this via a ClassMethod somewhere, and then just invoke that method in module.xml?)
Comments
When setting up a web application using Delegated Authentication via InterSystems IPM and ZAUTHENTICATE, you need to address the issue of automatically enabling Delegated Authentication because it doesn't appear to work directly through module.xml. Here's how you can resolve this systematically and implement this authentication mechanism:
ZAUTHENTICATE Routine Setup:
- Create a custom
ZAUTHENTICATEroutine in the%SYSnamespace. This serves as the main entry point for implementing your authentication logic. Example:
The routine verifies the passed credentials and sets user properties likeZAUTHENTICATE(ServiceName, Namespace, Username, Password, Credentials, Properties) PUBLIC { set tRes=$SYSTEM.Status.OK() try { set Properties("FullName")="OAuth account "_Username set Properties("Username")=Username set Properties("Roles")=Password } catch (ex) { set tRes=$SYSTEM.Status.Error($$$AccessDenied) } quit tRes }RolesandFullNameas required [1][2].
- Create a custom
Enable Delegated Authentication Globally:
Enable Delegated Authentication for Specific Applications:
- In your Web Application (
module.xml), include theAutheEnabledfield to configure delegated authentication:
This marks the authentication type for the app as "delegated" [1][2].<WebApplication Name="/${namespaceLower}/api" NameSpace="${namespace}" DispatchClass="pkg.isc.genai.rest.Handler" MatchRoles=":%All" AutheEnabled="#{$$$AutheDelegated}" Recurse="1" CookiePath="/${namespaceLower}/" />
- In your Web Application (
Manually Adjust Authentication Options (as a workaround):
- If you still find that the Delegated checkbox is not appearing or operating via the SMP, manually ensure that the Web Session Options page has the necessary Delegated option enabled [1].
Automate Delegated Authentication through ClassMethod:
- To automate enabling Delegated Authentication, write an ObjectScript ClassMethod that sets the required configuration programmatically. For example:
Call this method in your setup process to apply the delegated setting directly [1].ClassMethod EnableDelegatedAuth(applicationName As %String) As %Status { set tApp = ##class(Security.Applications).%OpenId(applicationName) if tApp '= "" { set tApp.Delegated = $$$YES quit tApp.%Save() } quit $SYSTEM.Status.Error($$$GeneralError, "Invalid application name.") }
- To automate enabling Delegated Authentication, write an ObjectScript ClassMethod that sets the required configuration programmatically. For example:
Testing and Debugging:
- Verify if
ZAUTHENTICATEis being called during login attempts. - Use the audit log for %System/%Login/LoginFailure events to diagnose any authentication issues [1].
- Verify if
By establishing the proper backend with ZAUTHENTICATE and leveraging programmatic controls for system configurations, you can circumvent limitations in module.xml to enable Delegated Authentication seamlessly. [1][2]
Sources:
@Justin Millette, there are more settings to enable in the system to allow delegated access, e.g. a system-wide setting, mentioned in this great @Pravin Barton's article , also there is another one from @Yuri Marx
Also, I don't recommend using the WebApplication tag as it is not working properly yet; there is at least one important bug not solved: for example , CSPApplication works quite well.
Also, I see %all - I hope this is for development/demo usage only, as it is quite a generous role to use.
Apologies for the late response. I am aware that delegated access needs to be enabled system-wide, I am just looking for a way to automate that (that survives a docker build).
And yes, the %All is for development/demo usage :)