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 -
Method Summary
Modifier and TypeMethodDescriptiontech.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, userMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getRequestin classtech.riemann.nif.auth.service.HttpServletAuthService- Returns:
- HttpServletRequest实例
-
getResponse
public jakarta.servlet.http.HttpServletResponse getResponse()获取HttpServletResponse对象- Specified by:
getResponsein classtech.riemann.nif.auth.service.HttpServletAuthService- Returns:
- HttpServletResponse实例
-
userDetailService
public tech.riemann.nif.auth.service.UserDetailService userDetailService()获取用户详情服务- Specified by:
userDetailServicein classtech.riemann.nif.auth.service.HttpServletAuthService- Returns:
- UserDetailService实例
-
cookieSettings
public tech.riemann.nif.auth.service.CookieSettings cookieSettings()获取Cookie配置- Overrides:
cookieSettingsin classtech.riemann.nif.auth.service.HttpServletAuthService- Returns:
- CookieSettings实例
-
jwtEncoder
public tech.riemann.nif.auth.jwt.JWTEncoder jwtEncoder()获取JWT编码器此实现不支持Token生成,调用此方法会抛出异常
- Specified by:
jwtEncoderin classtech.riemann.nif.auth.service.HttpServletAuthService- Returns:
- 总是抛出UnsupportedOperationException
- Throws:
UnsupportedOperationException- 不支持此操作
-
jwtDecoder
public tech.riemann.nif.auth.jwt.JWTDecoder jwtDecoder()获取JWT解码器- Specified by:
jwtDecoderin classtech.riemann.nif.auth.service.HttpServletAuthService- Returns:
- JWTDecoder实例
-