I am trying to setup a web service which uses x509 client certificates sent during the TLS handshake for authentication as well as to check whether the user has the auhorization to access the requested ressource.
The idea is that each user is givenan access level, and some ressources are only available to the higher levels. The certificate is then used to match the user to its level.
I have had no problem configuring Apache to verify the certificate against the root CA and to forward the certificate to the back-end application ( a python-based XML-RPC server).
However I am struggling to choose which attribute(s) of the certificate I should use to map the user to his level :
- The Common Name field seems like a natural choice, but I am wondering how secure this solution would be as nothing prevents multiple intermediary CAs from providing certificates with the same CN
- The Public Key itself is clearly more secure, but how practical is it to use ? Will it stay the same if the client has to renew his certificate after its expiry ? There is also the problem of storage and speed of comparison of a much larger string
- The whole certificate itself or its thumprint thumbprint could be an alternative to the public key, but the client will not be able to connect if his certificate is renewed
I am currently leaning towards the public key, but is it the best choice in this situation ? Or is there a better option ?
Thanks in avance