In 2019, as part of the update project from ASP.NET (.NET 4.6) to ASP.NET Core (.NET Core), the Virto Commerce team faced the challenge of replacement for AspNet.Security.OpenIdConnect.Server (ASOS). It is a low-level OpenID Connect OWIN/Katana that had been used for securing and token authentication for Virto Commerce Web API before that was included as part of ASP.NET Core and worked on even the most recent versions.
We chose the JWT token for authentication for the Virto Commerce platform RESTful endpoints because of the following advantages:
- Stateless – The token contains all the information to identify the user, eliminating the need for a session state.
We rejected some stateful (session) tokens that OpenIddict provides in the early version based on the following:
- Reusability – Separate servers running on multiple platforms and domains can reuse the same token for authenticating the user. It is easiest to build an application that shares permissions with other applications.
- JWT Security – No cookies are required to protect against cross-site request forgery attacks (CSRF).
It is necessary to add the following about the format of tokens – if you can avoid adding CSRF/anti-forgery countermeasures when using tokens, it's not related to the format they use (mentioned as JWT above), but it's due to the fact that they are not automatically attached to every request sent to a domain by browsers like cookies (they are typically attached to the Authorization header by the client app).
- Performance – No server-side lookup to find and deserialize the session on each request; you only need to calculate the HMAC SHA-256 to validate the token and parse its content.
Here are the main requirements by which we were guided:
- Issue and consume JWT tokens for authentication;
- Consume JWT tokens, which are issued by external authorization servers, since the Virto Commerce platform solution can be hosted as a set of independent, shared-to-nothing services (microservices architecture);
- Support OpenIdConnect and OAuth 2.0 non-interactive flows (password and client credentials flows, with refresh tokens);
- Native integration with ASP.NET Core and local user information storages (user provisioning) with ASP.NET Core Identity; and
- SSO with Identity Access Management systems such as Azure AD.
There were only two open-source projects at the moment, including IdentityServer and OpenIddict, but we rejected IdentityServer since it hadn't adopted well to .NET Core. Also, OpenIddict is a little bit more low-level than IdentityServer. IdentityServer gives you a running solution out of the box, whereas for OpenIddict to work, you need to implement some details yourself. It was an ideal solution for us at that moment because “less is more”, and we didn’t want to introduce extra complexity to our solution.
Finally, we continued with OpenIddict since it satisfied all our requirements and was natively integrated with the ASP.NET Core Identity membership system. As it turned out, in the future, the creators/maintainers of IdentityServer decided to dual-license future versions of IdentityServer. Now, unless you are working on an open-source project, you will have to pay for a commercial license, so we did not make a wrong choice (as it seems to us).
An example would be a recent blog post about IdentityServer alternatives, which they called "bare metal"; see this here.
Kévin Chalet, author of OpenIddict, commented: "In 2020, ASOS was merged into OpenIddict 3.0 to form a unified stack under one library, which we no longer needed."