验证Microsoft SignIn响应 [英] Verify Microsoft SignIn response

查看:106
本文介绍了验证Microsoft SignIn响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


很抱歉,如果这不是正确的论坛。


在我们的服务中(Java / Spring中的后端,React中的前端)我们实现了Google登录。


登录过程的最终结果是前端从Google接收一个重新发送到后端的对象。后端验证(使用Google库)对象有效并从中提取用户信息。像这样:

 

public void authenticateGoogleUser(Object googleInfo){
LinkedHashMap< String,String> map =(LinkedHashMap)googleInfo;
String tokenId = map.get(" tokenId" );
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(...)。build();
GoogleIdToken googleIdToken = verifier .verify(tokenId); //验证tokenId是否有效
GoogleIdToken.Payload payload = googleIdToken.getPayload();
String userId = payload.getSubject();
String email = payload.getEmail();

//等。

}

现在我们要使用Microsoft登录实现相同的功能。

前端显示Microsoft SignIn按钮,用户登录,

前端接收Microsoft SignIn响应对象并将其重新发送到后端服务器。

我们的问题是:我们如何验证这一点后端服务器中的响应?

是否有一个库可以执行此操作,如GoogleIdTokenVerifier?

 

谢谢你





解决方案

Hello  Zvezdomir
Savov
, 


你应该能够达到这个目的。你能不能请一个查看以下客户端库。 


ADAL: -   https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/wiki


MSAL: -   https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki <一个href ="https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/wiki">


希望这些信息可以帮助您实施。 &NBSP;


Hi,

Sorry if this is not the right forum.

In our service (back-end in Java/Spring, front-end in React) we implemented Google Sign in.

The end result of the Sign In process is that the front-end receives an object from Google which it re-sends to the back-end. The back-end verifies (with a Google Library) that the object is valid and extracts user info from it. Like this:

public void authenticateGoogleUser(Object googleInfo){
LinkedHashMap<String, String> map = (LinkedHashMap) googleInfo;
String tokenId = map.get("tokenId");
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(...).build();
GoogleIdToken googleIdToken = verifier.verify(tokenId);// verify that the tokenId is valid
GoogleIdToken.Payload payload = googleIdToken.getPayload();
String userId = payload.getSubject();
String email = payload.getEmail();

// etc.

}

Now we want to implement the same functionality with Microsoft Sign in.

The front end shows the Microsoft SignIn button, user signs in,

front-end receives the Microsoft SignIn response object and re-sends it to the back-end server.

Our question is: How do we validate this response in the back-end server?

Is there a library that does it, like the GoogleIdTokenVerifier?

Thank you




解决方案

Hello Zvezdomir Savov

You should be able to achieve this as far as I can think. Could you please take a look at the following client side libraries. 

ADAL :- https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/wiki

MSAL :- https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki

Hope this information helps you in your implementation . 


这篇关于验证Microsoft SignIn响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆