Class CacheableOpenIDConnectionAuthService

java.lang.Object
tech.riemann.nif.auth.service.HttpServletAuthService
tech.riemann.nif.oidc.service.CacheableOpenIDConnectionAuthService
All Implemented Interfaces:
tech.riemann.nif.auth.service.AuthService

public class CacheableOpenIDConnectionAuthService extends tech.riemann.nif.auth.service.HttpServletAuthService
基于OpenID Connect的可缓存认证服务

继承自HttpServletAuthService,提供基于OIDC的认证服务实现

主要特点: 1. 支持Token验证缓存,减少重复的JWT解码操作 2. 通过HttpServletRequest和HttpServletResponse管理Cookie 3. 不支持Token生成(jwtEncoder方法抛出UnsupportedOperationException)

使用场景: - 适用于OIDC客户端,只需要验证Token,不需要生成Token - 适用于多节点部署,需要共享认证状态的场景

注意: - 此类不支持Token刷新,因为jwtEncoder()方法会抛出异常 - 如果需要Token刷新功能,应使用其他AuthService实现 - H10:默认禁止从 URL query 参数获取 Token(继承 HttpServletAuthService.allowQueryToken() 默认 false);确需支持时覆写该方法返回 true

Author:
Kerbores(kerbores@riemann.tech)
  • Field Summary

    Fields inherited from class tech.riemann.nif.auth.service.HttpServletAuthService

    TOKEN_EXPIRED
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    tech.riemann.nif.auth.service.CookieSettings
    获取Cookie配置
    jakarta.servlet.http.HttpServletRequest
    获取HttpServletRequest对象
    jakarta.servlet.http.HttpServletResponse
    获取HttpServletResponse对象
    tech.riemann.nif.auth.jwt.JWTDecoder
    获取JWT解码器
    tech.riemann.nif.auth.jwt.JWTEncoder
    获取JWT编码器
    tech.riemann.nif.auth.service.UserDetailService
    获取用户详情服务

    Methods inherited from class tech.riemann.nif.auth.service.HttpServletAuthService

    addCookie, allowQueryToken, authentication, authorizationHeaderKey, login, logout, optionalUser, pass, refreshToken, refreshToken, refreshTokenKey, skip, subject, token, token, tokenKey, tokenOrRefreshToken, tryRefreshToken, user

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface tech.riemann.nif.auth.service.AuthService

    permissions, roles, userName
  • Constructor Details

    • CacheableOpenIDConnectionAuthService

      public CacheableOpenIDConnectionAuthService()
  • Method Details

    • getRequest

      public jakarta.servlet.http.HttpServletRequest getRequest()
      获取HttpServletRequest对象
      Specified by:
      getRequest in class tech.riemann.nif.auth.service.HttpServletAuthService
      Returns:
      HttpServletRequest实例
    • getResponse

      public jakarta.servlet.http.HttpServletResponse getResponse()
      获取HttpServletResponse对象
      Specified by:
      getResponse in class tech.riemann.nif.auth.service.HttpServletAuthService
      Returns:
      HttpServletResponse实例
    • userDetailService

      public tech.riemann.nif.auth.service.UserDetailService userDetailService()
      获取用户详情服务
      Specified by:
      userDetailService in class tech.riemann.nif.auth.service.HttpServletAuthService
      Returns:
      UserDetailService实例
    • cookieSettings

      public tech.riemann.nif.auth.service.CookieSettings cookieSettings()
      获取Cookie配置
      Overrides:
      cookieSettings in class tech.riemann.nif.auth.service.HttpServletAuthService
      Returns:
      CookieSettings实例
    • jwtEncoder

      public tech.riemann.nif.auth.jwt.JWTEncoder jwtEncoder()
      获取JWT编码器

      此实现不支持Token生成,调用此方法会抛出异常

      Specified by:
      jwtEncoder in class tech.riemann.nif.auth.service.HttpServletAuthService
      Returns:
      总是抛出UnsupportedOperationException
      Throws:
      UnsupportedOperationException - 不支持此操作
    • jwtDecoder

      public tech.riemann.nif.auth.jwt.JWTDecoder jwtDecoder()
      获取JWT解码器
      Specified by:
      jwtDecoder in class tech.riemann.nif.auth.service.HttpServletAuthService
      Returns:
      JWTDecoder实例