I am trying to implement TLS based authentication, basically SSL certificate based authentication, when two-way SSL is enabled in Geode cluster. Authentication is performed based on certificate DN. Lets say client/peer node configured with two-way ssl of certificate "cn=example.com,ou=org,location=us", authentication and authorization should only be successful if "example.com" is valid cert and authorize accordingly. I see that Geode authentication implementation is based on security-username/password and security Manager Geode implementation does not provide better way to access connection peer certificates. I was not able to find related documentation, any direction on this kind of requirement would be helpful.
Thanks.
As you may already be familiar based on the comments in your question above, I encourage you to first re-review the section on SSL in the Security chapter of Apache Geode's documentation. SSL would be a prerequisite for everything I am about to suggest below.
Apache Geode's Security implementation of Authentication (as well as Authorization) is based on Apache Geode's
SecurityManagerinterface as well as theAuthInitializeinterface.The
SecurityManageris used on the server-side to authenticate clients (or additional peers joining the P2P cluster as a member). An implementation of theAuthInitializeinterface is used by clients (or other peers joining the P2P cluster as a member) to supply the credentials.The supplied
SecurityManagerimplementation is configured with the[gemfire.]security-managerproperty. TheAuthInitializeimplementation is configured with the[gemfire.]security-client-auth-initproperty (or the[gemfire.]security-peer-auth-initproperty).While Apache Geode's documentation commonly refers to username/password-based authentication for Geode nodes (clients and peers), the fact of the matter is, the
Propertiesreturned by the (client-side)AuthInitialize.getCredentials(..)(Javadoc) method and processed on the server-side,SecurityManager.authenticate(:Properties)(Javadoc) could contain the appropriate certificate and evidence as described (for example) here.It is not uncommon for Password-based authentication to be used with Certificate-based authentication (both over SSL).
In which, case you could do the following. On the client-side:
Then configure your client with:
The server-side, custom
SecurityManagerimplementation would then use the credentials to authenticate the client.If the servers's in the Apache Geode cluster were configured and bootstrapped with Spring, then you would configure your custom
SecurityManagerimplementation using:If you used Gfsh to start the Locators and Servers in your cluster, then refer to Apache Geode's documentation to configure properties on startup.
As you may also be aware (based on your tags), Apache Geode integrates with Apache Shiro. Unfortunately, I did not find any support in Apache Shiro for Certificate-based Authentication (here), which introduces the concept of
Realmsfor auth, where the availableRealmsprovided by Apache Shiro are here (you can see support for ActiveDirectory, JDBC, JNDI, LDAP, and text-basedRealms).Of course, you could also devise an implementation of Apache Geode's
SecurityManagerinterface along with theAuthInitializeinterface, integrated with Spring Security and follow the general advice in Baeldung's blog post.Hopefully this gives you enough to think about and some ideas on how to go about implementing Certificate-based Authentication between clients and servers (and peers?) in your [Spring] Apache Geode application/cluster.