🎨 Improving structure / format of the code.
This commit is contained in:
1 parent
19b0d32d11
commit
1d4d76cbb1
2 files changed
+4
-5
No files matched your search
@@ -58,7 +58,6 @@ import java.util.Map;
|
||||
@RequestMapping("/token")
|
||||
public class PigxTokenEndpoint {
|
||||
private static final String PIGX_OAUTH_ACCESS = SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX + "auth_to_access:";
|
||||
private static final String PIGX__ACCESS = SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX + "access:";
|
||||
private final TokenStore tokenStore;
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final CacheManager cacheManager;
|
||||
@@ -87,7 +86,7 @@ public class PigxTokenEndpoint {
|
||||
.msg("退出失败,token 为空").build();
|
||||
}
|
||||
|
||||
String tokenValue = authHeader.replace("Bearer", "").trim();
|
||||
String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StrUtil.EMPTY).trim();
|
||||
OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
|
||||
if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) {
|
||||
return R.builder()
|
||||
|
||||
+3
-3
@@ -89,10 +89,10 @@ public class PigxWebResponseExceptionTranslator implements WebResponseExceptionT
|
||||
|
||||
int status = e.getHttpErrorCode();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Cache-Control", "no-store");
|
||||
headers.set("Pragma", "no-cache");
|
||||
headers.set(HttpHeaders.CACHE_CONTROL, "no-store");
|
||||
headers.set(HttpHeaders.PRAGMA, "no-cache");
|
||||
if (status == HttpStatus.UNAUTHORIZED.value() || (e instanceof InsufficientScopeException)) {
|
||||
headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, e.getSummary()));
|
||||
headers.set(HttpHeaders.WWW_AUTHENTICATE, String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, e.getSummary()));
|
||||
}
|
||||
|
||||
// 客户端异常直接返回客户端,不然无法解析
|
||||
|
||||
Reference in new issue
Block a user