Configuring OERealm Authentication
Setting Up The Server
The following steps only have to be carried out once per server instance - however, the settings used will be required whenever you are configuring a new REST project, so keep note of them.
- If you are using the Pacific Application Server, open
<Server Folder>/conf/jvm.propertiesthen add or update the following setting:
-Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false
Open a Proenv command prompt and use the
cdcommand to navigate to your desktop.Generate a Client-Principal file using the
genspacp.batutility. This will be used to secure the HybridRealm class from being called by other PASOE clients. Note that this tool only exists in development installs of OpenEdge - you won't be able to run it on the server itself.
genspacp -password <Password> -role <Role Name>
genspacp 1.0
Generated sealed Client Principal...
User: BPSServer@OESPA
Id: SmjnCQ1kTm2fY5r8pxQg5A
Role: <Role Name>
Encoded Password: <Encoded Password>
File: oespaclient.cp
State: SSO from external authentication system
Seal is valid
Copy the file generated by the utility (which will be called
oespaclient.cpby defaultt) to:<OpenEdge Work Folder>/<Server Name>/common/lib, if using the Pacific Application Server.<Project Root>/RESTContent/WEB-INF/classes, if using the classic AppServer.
Create a new plain-text file called
spaservice.properties, and enter the following options. Some important things to note:- The
Passwordrefers to the encoded password returned bygenspacp, not the plain-text one entered on the command-line. - Make sure a blank line is left at the end of the file! Not doing this can lead to strange errors when the file is being parsed.
- The
Password=<Encoded Password>
Role=<Role Name>
DebugMsg=true
- Save
spaservice.propertiesto<Server Folder>/openedgeif using Pacific Application Server, or your server's OpenEdge work folder if using a classic AppServer.
Configuring Spring Security
These steps need to be carried out every time you create a new project, regardless of whether there are other projects running on the same server instance.
- Create an implementation of IHybridRealm and a Properties class in
<Project Root>/AppServer/auth. Examples can be found on Progress KnowledgeBase. - Inside your project directory, open the
WEB-INFfolder for your chosen server configuration - if you are using a Pacific Application Server instance, this will be<Project Root>/PASOEContent/WEB-INF, whilst on a classic AppServer this will be<Project Root>/RESTContent/WEB-INF. - In
WEB-INF/web.xml, setcontextConfigLocationto either/WEB-INF/oeablSecurity-form-oerealm.xmlor/WEB-INF/oeablSecurity-basic-oerealm.xml, depending on which authentication method you want to utilize. Basic authentication is stateless, requiring a username and password to be sent in the header of each HTTP request, whereas Form authentication uses cookie-based sessions.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
<!-- USER EDIT: Select which application security model to employ
/WEB-INF/oeablSecurity-basic-local.xml
/WEB-INF/oeablSecurity-anonymous.xml
/WEB-INF/oeablSecurity-form-local.xml
/WEB-INF/oeablSecurity-container.xml
/WEB-INF/oeablSecurity-basic-ldap.xml
/WEB-INF/oeablSecurity-form-ldap.xml
/WEB-INF/oeablSecurity-basic-oerealm.xml
/WEB-INF/oeablSecurity-form-oerealm.xml
/WEB-INF/oeablSecurity-form-saml.xml
/WEB-INF/oeablSecurity-basic-saml.xml
-->
/WEB-INF/oeablSecurity-basic-oerealm.xml
</param-value>
</context-param>
- Open the configuration file that you specified in the previous step.
- Configure
OERealmAuthProviderwith the following settings.keyshould be set to the encoded password returned bygenspacp.- If
sealClientPrincipalis set to false, the client principal object will be passed through theOEClientPrincipalFilter, found in the same configuration file. This allows for a little more control over the object, but at the expense of added complexity - unless you have a specific reason to utilize the settings inOEClientPrincipalFilter, it is probably a good idea to set this totrue.- This option was added in OpenEdge 11.6, and will not be present if configuring earlier versions.
- If you want to use the built-in OpenEdge user domains/database table, set
userDomainto the name of the domain, and setauthztotrue. However, if you have a custom user table/authentication system,userDomainmust be blank, andauthzmust befalse. If you get this wrong, things will not work!
<b:bean id="OERealmAuthProvider"
class="com.progress.appserv.services.security.OERealmAuthProvider" >
<b:property name="userDetailsService">
<b:ref bean="OERealmUserDetails"/>
</b:property>
<b:property name="createCPAuthn" value="true" />
<b:property name="sealClientPrincipal" value="true" />
<b:property name="multiTenant" value="false" />
<b:property name="userDomain" value="" />
<b:property name="key" value="<Encoded Password>" />
<b:property name="authz" value="false" />
</b:bean>
- Configure
OERealmUserSettingswith the following settings.realmURL's value will vary depending on what type of application server is being used:- For a remote classic AppServer using NameServer, use
AppServer[s]://<Name Server Host>:<Name Server Port>/<Broker Name>. - For a remote classic AppServer using DirectConnect, use
AppServerDC[s]://<AppServer Host>:<AppServer Port>/<Broker Name>. - For a remote classic AppServer using AIA, use
http[s]://<Host>[:<Port>]/<AIA App Name>/aia. - For a remote Pacific Application Server, use
http[s]://<Host>[:<Port>]/<OEABL App Name>/apsv. This requires the APSV transport to be enabled on your ABL application - follow the steps outlined in Progress' documentation to ensure this is set up correctly. - For a local Pacific Application Server, use
internal://localhost/nxgas.
- For a remote classic AppServer using NameServer, use
realmClassshould be set to the namespaced path of your HybridRealm class. If you are using the example implementation, this will probably beauth.HybridRealm.realmPwdAlgsets the algorithm that the server should use to validate the user's credentials. If the value is0, the data will be sent from Spring to the AppServer using HTTP Basic authentication in cleartext. If the value is3, the data will be sent using HTTP Digest authentication, which encodes the password before sending it to the AppServer. Note that this does not apply to the connection from the client to the server - there is currently no way to use digest auth for the outward facing connection.realmTokenFileshould be set to the filename of the client-principal file generated bygenspacp. Unless you went out of your way to rename it, this should beoespaclient.cp.
<b:bean id="OERealmUserDetails"
class="com.progress.appserv.services.security.OERealmUserDetailsImpl" >
<b:property name="realmURL" value="http://<Host Name>:<Port>/<Application Name>/apsv" />
<b:property name="realmClass" value="<HybridRealm Class>" />
<b:property name="grantedAuthorities" value="ROLE_PSCUser" />
<b:property name="rolePrefix" value="ROLE_" />
<b:property name="roleAttrName" value="ATTR_ROLES" />
<b:property name="enabledAttrName" value="ATTR_ENABLED" />
<b:property name="lockedAttrName" value="ATTR_LOCKED" />
<b:property name="expiredAttrName" value="ATTR_EXPIRED" />
<b:property name="realmPwdAlg" value="3" />
<b:property name="realmTokenFile" value="oespaclient.cp" />
<!-- For SSL connection to the oeRealm appserver provide the complete
path of psccerts.jar as the value of 'certLocation' property
-->
<b:property name="certLocation" value="" />
<!-- set appendRealmError = true in order to append the Realm
class thrown error in the error details send to the REST Client -->
<b:property name="appendRealmError" value="false" />
</b:bean>