The security framework provides authentication, authorization, and protection against common attacks.

ApiHug offers a minimalist and efficient security solution, different from traditional frameworks like Apache Shiro or Spring Security.

It is still based on resource (API) permission management, combined with roles, creating a very simple RBAC (Role-Based Access Control) structure that is ready to use out of the box.

Protocol

How to define the protocol at the Proto layer: Minimal Authentication & Authorization

Implementation

  1. SecurityAspect: Aspect
  2. SecurityContext: Runtime security context, including resource to CheckerAuthorization mapping
  3. HopeSecurityManager: Runtime security parameter assembly
  4. JWTFilter: JWT filter

Currently, the Aspect SecurityAspect only supports BEFORE checks, meaning it validates before entering the resource (API) business logic.

Configuration

Configuration path: hope.security; Configuration object: HopeSecurityProperties.

ConfigurationRemarks
enabledWhether to enable ApiHug Security.
jwtJWT configuration.
jwt.base64SecretBase64 secret.
jwt.secretSecret.
jwt.tokenValidityInSecondsForRememberMeValidity period for Remember Me, default is 30 days.
jwt.tokenValidityInSecondsDefault validity time, 7 days.

To be done 🏗️

Refer

  1. Authentication & Authorization
  2. Spring Security
  3. Apache Shiro
  4. RBAC - Role-based access control