Penguin Geeks | Choosing User Authentication Technologies for Pharmaceutical AI, Big Data, and Diverse Application Scenarios: OAuth2 or CAS
Article images may contain Chinese text.

With the rapid development of AI, big data, various application technologies, and the underlying technologies of hardware and software
across multiple device types, pharmaceutical companies face user login experience challenges involving multiple systems, multiple data sources, and access from multiple devices. This article primarily presents several considerations in how Weiming Penguin selects authentication technologies to support flexible changes in users' identity relationships and access permissions across its own AI, big data, and application systems and the surrounding ecosystem, while safeguarding data security. It focuses on the differences between Oath2 and CAS and offers recommendations for choosing between them in different scenarios.

In modern applications, authentication is a key step in ensuring that user identities are genuine and reliable. It verifies whether users are who they claim to be and allows them to access restricted resources. Common authentication methods include:
Username and password login: The most basic authentication method, but one that carries a risk of password exposure.
SMS verification codes: Authentication using a verification code sent by text message, enhancing security but carrying risks of interception and abuse.
OAuth2: An authorization framework that allows users to use third-party authentication, such as WeChat or GitHub login.
CAS (Central Authentication Service): A single sign-on (SSO) solution that allows users to log in seamlessly across multiple systems.
This article focuses on the principles, implementations, and applicable scenarios of the two authentication solutions, OAuth2 and CAS.

Introduction to OAuth2

OAuth2 (Open Authorization 2.0) is an open-standard authorization framework that allows users to authorize third-party applications to access their resources without exposing their passwords. Its core idea is token-based access control, avoiding the security issues associated with traditional usernames and passwords.
OAuth2 primarily involves four roles:
Resource Owner: The user who authorizes a third party to access their protected resources.
Resource Server: The server that stores protected resources, such as an API.
Authorization Server: Responsible for authenticating the user and issuing an Access Token.
Client: The third-party application that requests authorization and then uses a token to access the resource server.
OAuth2 Authentication Flow

OAuth2 primarily has four authorization grant types. The most common is the Authorization Code grant, which follows this flow:
The user accesses the client, for example through a GitHub login button.
The client redirects the user to the authorization server (the OAuth2 authentication URL), passing information such as client_id and redirect_uri.
The user logs in and grants authorization, and the authorization server returns an Authorization Code.
The client submits the authorization code to the authorization server to request an Access Token. After validation, the authorization server returns the Access Token, which the client can then use to access the resource server (API).
Implementing OAuth2 Authentication with Spring Security

Spring Security provides comprehensive OAuth2 support. The following is an example of building an OAuth2 authorization server with Spring Boot.


Introduction to CAS

CAS (Central Authentication Service) is a single sign-on (SSO) solution primarily used in enterprise applications. It allows users to log in once and access multiple systems without repeatedly entering their username and password.
CAS Authentication Flow

The user accesses subsystem A. System A detects that the user is not logged in and redirects them to the CAS server for authentication.
The user logs in to the CAS server. After a successful login, the CAS server generates a ticket (TGT, Ticket Granting Ticket) and stores it in a cookie.
The CAS server generates a service ticket (ST, Service Ticket) and returns it to system A.
System A submits the ST to the CAS server for validation. Once validation succeeds, system A allows the user access. When the user accesses subsystem B, B finds that the user's cookie already contains a TGT, obtains an ST directly without requiring another login, and validates it. After successful validation, the user can access the system seamlessly.


A Multidimensional Comparison of OAuth2 and CAS


Recommended Use Cases

OAuth2 is suitable for mobile applications, API authorization, and third-party login, such as GitHub and WeChat authorization.
CAS is suitable for internal enterprise single sign-on, allowing multiple web systems to share login status.

