如何使用spring cloud azure starter active directory获取身份验证URL和用户ID?
https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory
我知道AD身份验证可以使用以下URL的源代码,但我想在日志中输出用户和身份验证URL。
- 验证URL
https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/authorize?response_type=code&client_id={clinet_id}
- 登录用户ID
user001@tenant.onmicrosoft.com
重定向是未知的,但用户ID可以以以下格式输出
@GetMapping("Adimn")
public ModelAndView Adimn(HttpServletRequest request) {
try {
String userId = request.getUserPrincipal().getName();
log.info(userId);
return new ModelAndView("redirect:" + "/index");
}
以下是可以获得重定向uri的示例代码:
@GetMapping("azure/redirect-uri")
public String azureRedirectUri(@RegisteredOAuth2AuthorizedClient("azure") OAuth2AuthorizedClient azure) {
return azure.getClientRegistration().getRedirectUri();
}
其它信息如";客户端id";也可以通过";azure.getClientRegistration.getXxx(("。