Can OAuth client configurations be exported/copied from one instance to another?
Hi all,
I'm performing a migration of some services from one instance to another, and I noticed that the technique defined within the InterSystems Server Migration Guide does not include OAuth client configurations. The recommended technique is to use the ##class(Security.System).ExportAll() and ##class(Security.System).ImportAll() methods.
Is there a way to migrate OAuth client configurations, or do those have to be re-created manually?
Comments
Within the %SYS namespace the OAuth2 package can be leveraged. I don't know if there is already a method within that package to accomplish a simple export and import. However, you can absolutely program the autocreation of the OAuth configurations. In one of my implementations I was asked to setup a framework to auto create everything via a JSON "settings" file. To implement I simply looped the OAuth portion of the settings file and then for each OAuth config I set the following p variables:
Set tClient=##class(OAuth2.Client).Open(pApplicationName)If '$isobject(tClient) {Set tClient = ##class(OAuth2.Client).%New()Set tClient.ApplicationName = pApplicationName}Set tClient.AuthenticationType ="basic"Set tClient.ClientId=pClientIDSet tClient.ClientSecret=pClientSecretSet tClient.ClientType="confidential"Set tClient.Enabled=1Set tClient.EncryptionAlgorithm=""Set tClient.KeyAlgorithm=""Set tClient.RedirectionEndpoint.Host=pHostNameSet tClient.SSLConfiguration=pSslConfigurationSet tClient.ServerDefinition=pServerConfigSet tClient.SigningAlgorithm=""Set tSC=tClient.%Save()If $$$ISERR(tSC) quitSet tClient=##class(OAuth2.Client).Open(pApplicationName)Set metadata = tClient.MetadataSet metadata."grant_types"=$lb("authorization_code")Set tClient.Metadata = metadataSet tSC=tClient.%Save()
Thanks Chris! I just took a look and I can use those classes for a custom export/import.
Can the import/export code finally used Mike be shared as a solution for this? Would be useful
Hi Developers!
A new idea Exporting OAuth Server/Client Configs using ^SECURITY or another method was posted on the InterSystems Ideas based on this discussion. If you support this idea please vote for it in the Ideas Portal.
Other option from WRC we were told.
Export and import the OAUTH2 globals and import