繁体   English   中英

如何使用 ADFS 在 IOS 上实现 SSO 功能

[英]How to implement SSO functionality on IOS using ADFS

我想使用ADFSIOS single sign-on实现single sign-on功能。 我做了一些研发并尝试使用MSAL iOS库进行ADFS身份验证,但它对我不起作用。

我为 ADFS 身份验证添加了客户端 ID、权限 URL,但它对我不起作用。 每次它给我Couldn't acquire token错误。

我有不同的SSO URL ,所以不使用Microsoft azure server

我尝试以下列方式为MSAL IOS库添加我的凭据

let kClientID = "xxxxxx-8929-4D60-B869-xxxxxxxx"

// These settings you don't need to edit unless you wish to attempt deeper scenarios with the app.
let kGraphURI = "https://graph.microsoft.com/v1.0/me/"
let kScopes: [String] = ["https://graph.microsoft.com/user.read"]
let kAuthority = "https://fs.example.com/adfs/oauth2"

任何的想法?

这里我们不需要使用 MSAL iOS。 有一个使用 Microsoft docs 的简单解决方案。 按照链接:

https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/overview/ad-fs-scenarios-for-developers

我们只需要形成一个url字符串

https://fs.xxx.com/adfs/oauth2/authorize?response_type=code&client_id=xxxx-xxxx-xxxx-xxxx-xxxxxxx&redirect_uri=appName://&resource=http://xxxx/workflow

这将生成一个代码,我们可以在 App Delegate 的 openUrl 方法中获取该代码,然后我们需要使用参数创建一个 post 请求:

grant_type:authorization_code
code: xxxxx ( we got from get request)
redirect_uri: appName://
resource:http://xxxx/workflow

就是这样 。 我们将获得 access_token,我们可以进一步使用它来获取 userProfile 等。

希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM