当前位置:网站首页>Unified certification center oauth2 certification pit
Unified certification center oauth2 certification pit
2022-06-10 15:37:00 【InfoQ】
cas-server-url: http://cas-server-service # The configuration here is HA Address
security:
oauth2: # And cas-server Corresponding configuration
client:
client-id: admin-web
client-secret: admin-web-123
user-authorization-uri: ${cas-server-url}/oauth/authorize # It is required by the authorization code authentication method
access-token-uri: ${cas-server-url}/oauth/token # It's the access required by password mode token The interface of
resource:
loadBalanced: true
id: admin-web
user-info-uri: ${cas-server-url}/api/user # Appoint user info Of URI
prefer-token-info: false
/**
* Return all discovered Services
* @author Damon
* @date 2021 year 11 month 2 Japan Afternoon 8:18:44
* @return
*
*/
@PreAuthorize("hasRole('admin')")
@GetMapping(value = "/getService")
public String getService(){
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<String> formEntity = new HttpEntity<String>(null, headers);
String body = "";
try {
ResponseEntity<String> responseEntity = restTemplate.exchange("http://cas-server/api/v1/user",
HttpMethod.GET, formEntity, String.class);
if (responseEntity.getStatusCodeValue() == 200) {
return "ok";
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
return body;
}
@PreAuthorize("hasRole('admin')")

2021-11-03 15:59:09.385 DEBUG 127896 --- [io2-2001-exec-4] org.springframework.web.HttpLogging : HTTP GET http://cas-server/auth/user
2021-11-03 15:59:09.389 DEBUG 127896 --- [io2-2001-exec-4] org.springframework.web.HttpLogging : Accept=[application/json, application/*+json]
2021-11-03 15:59:09.427 DEBUG 127896 --- [io2-2001-exec-4] org.springframework.web.HttpLogging : Response 404 NOT_FOUND
2021-11-03 15:59:09.446 DEBUG 127896 --- [io2-2001-exec-4] o.s.w.c.HttpMessageConverterExtractor : Reading to [org.springframework.security.oauth2.common.exceptions.OAuth2Exception]
2021-11-03 15:59:09.456 WARN 127896 --- [io2-2001-exec-4] o.s.b.a.s.o.r.UserInfoTokenServices : Could not fetch user details: class org.springframework.web.client.HttpClientErrorException$NotFound, 404 : [{"timestamp":"2021-11-03T07:59:09.423+00:00","status":404,"error":"Not Found","message":"","path":"/auth/user"}]
2021-11-03 15:59:09.457 ERROR 127896 --- [io2-2001-exec-4] c.l.h.CustomAuthenticationEntryPoint : invalid token, Please re authenticate to visit
{"data":"b34841b4-61fa-4dbb-9e2b-76496deb27b4","result":{"code":20202,"msg":" Uncertified ","status":401}}
404 invalid token, Please re authenticate to visit {"data":"b34841b4-61fa-4dbb-9e2b-76496deb27b4","result":{"code":20202,"msg":" Uncertified ","status":401}}4042021-11-03 15:59:09.407 DEBUG 54492 --- [o2-2000-exec-15] o.s.web.servlet.DispatcherServlet : GET "/auth/user", parameters={}
2021-11-03 15:59:09.409 DEBUG 54492 --- [o2-2000-exec-15] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"]
2021-11-03 15:59:09.413 DEBUG 54492 --- [o2-2000-exec-15] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2021-11-03 15:59:09.414 DEBUG 54492 --- [o2-2000-exec-15] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
2021-11-03 15:59:09.422 DEBUG 54492 --- [o2-2000-exec-15] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
2021-11-03 15:59:09.423 DEBUG 54492 --- [o2-2000-exec-15] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)
2021-11-03 15:59:09.424 DEBUG 54492 --- [o2-2000-exec-15] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [application/json] and supported [application/json, application/*+json, application/json, application/*+json, application/json, application/*+json]
2021-11-03 15:59:09.424 DEBUG 54492 --- [o2-2000-exec-15] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [{timestamp=Wed Nov 03 15:59:09 CST 2021, status=404, error=Not Found, message=, path=/auth/user}]
2021-11-03 15:59:09.426 DEBUG 54492 --- [o2-2000-exec-15] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404
/auth/user@GetMapping("/api/v1/user")
public Authentication user(Map map, Principal user, Authentication auth) {
// Get current user information
logger.info("cas-server provide user: " + JSON.toJSONString(auth));
return auth;
}
cas-server-url: http://cas-server
security:
path:
ignores: /,/index,/static/**,/css/**, /image/**, /favicon.ico, /js/**,/plugin/**,/avue.min.js,/img/**,/fonts/**
oauth2:
client:
client-id: rest-service
client-secret: rest-service-123
user-authorization-uri: ${cas-server-url}/oauth/authorize
access-token-uri: ${cas-server-url}/oauth/token
resource:
loadBalanced: true
id: rest-service
prefer-token-info: false
user-info-uri: ${cas-server-url}/api/v1/user
authorization:
check-token-access: ${cas-server-url}/oauth/check_token

403"authorities": [ { "authority": "ROLE_admin" }, { "authority": "admin" }
{ "authorities": [ { "authority": "ROLE_admin" }, { "authority": "admin" } ], "details": { "remoteAddress": "0:0:0:0:0:0:0:1", "sessionId": null, "tokenValue": "b34841b4-61fa-4dbb-9e2b-76496deb27b4", "tokenType": "bearer", "decodedDetails": null }, "authenticated": true, "userAuthentication": { "authorities": [ { "authority": "ROLE_admin" }, { "authority": "admin" } ], "details": { "authorities": [ { "authority": "ROLE_admin" }, { "authority": "admin" } ], "details": { "remoteAddress": "169.254.200.12", "sessionId": null, "tokenValue": "b34841b4-61fa-4dbb-9e2b-76496deb27b4", "tokenType": "Bearer", "decodedDetails": null }, "authenticated": true, "userAuthentication": { "authorities": [ { "authority": "ROLE_admin" }, { "authority": "admin" } ],
...
summary
边栏推荐
- json.load(s)与json.dump(s)
- cmake实战记录(一)
- 自媒体视频热门思路分享
- Cmake actual combat record (I)
- Click to unlock "keyword" of guanghetong 5g module
- [cloud native | kubernetes] in depth RC, RS, daemonset, statefulset (VII)
- How to open an account for agricultural futures? Are there any financial conditions?
- Guanghetong cooperates with China Mobile, HP, MediaTek and Intel to build 5g fully connected PC pan terminal products
- How does CRM help enterprises and salespeople?
- In what scenario can we not use the arrow function?
猜你喜欢

100003 words, take you to decrypt the system architecture under the double 11 and 618 e-commerce promotion scenarios

Yuntu says that every successful business system cannot be separated from apig

RSA a little bit of thought

Digital management medium + low code, jnpf opens a new engine for enterprise digital transformation

港大、英伟达 | Factuality Enhanced Language Models for Open-Ended Text Generation(用于开放式文本生成的事实性增强语言模型)

After class assignment for module 8 of phase 6 of the construction practice camp

CentOS Linux is dead! Oracle Linux may be a better alternative

“绽放杯”5G应用奖项大满贯!广和通多个联合项目荣获通用产品专题赛一、二、三等奖

HKU and NVIDIA | factuality enhanced language models for open ended text generation

Golang beep package playback MP3 cannot get the total length streamer Len() is 0, but other formats can
随机推荐
We media video Hot Ideas sharing
22. Generate Parentheses
Guanghetong cooperates with China Mobile, HP, MediaTek and Intel to build 5g fully connected PC pan terminal products
Applet network request promise
Wechat applet color gradient
Vins Theory and Code detail 4 - Initialization
音视频处理三剑客之 AEC:回声产生原因及回声消除原理
影刀RPA学习和遇见excel部分问题解决方式
Baidu open source ice-ba installation and operation summary
Using GDB to quickly read the kernel code of PostgreSQL
Google Earth engine (GEE) - real time global 10 meter land use / land cover (LULC) data set based on S2 images
如何构建以客户为中心的产品蓝图:来自首席技术官的建议
What has guanghetong done in the three years of 5g business from "seeding in the first generation" to "flower on the ground"?
排名前十、手续费低的期货公司有哪些?安全吗
Common QR decomposition, SVD decomposition and other matrix decomposition methods of visual slam to solve full rank and deficient rank least squares problems (analysis and summary of the most complete
云图说|每个成功的业务系统都离不开APIG的保驾护航
Summary of 5 years' experience in ERP odoo privilege management system setup
农产品期货如何开户?有没有什么资金条件?
VINS理论与代码详解4——初始化
无线通信模组如何助力智能无人机打造“空中物联网”?