User Authentication through API using IdentityServer4

点点圈 提交于 2021-01-28 11:10:25

问题


I'm looking into IdentityServer4 as a possible solution for managing users and API access tokens. One thing that is not clear is if it's possible to provide authentication through API calls or are we forced to use a login page hosted by IdentityServer4?

With respect to user experience in mobile apps, it's always nicer to provide a simple login screen within the app, as opposed to opening a web page that handles the login process.

Are we forced to use a login / registration page hosted by IdentityServer4 or can it be handled through API calls?


回答1:


Login should occur on the IdentityServer website for the simple reason that a client can't be trusted with the user credentials.

When the user logs in on the IdentityServer website, the client remains ignorant of the credentials. The user is either authenticated or the request is rejected.

Please note that an embedded browser for a 'good user experience' is also not recommended, as this will require the user to enter the credentials in an unsafe environment (credentials could be captured), even when the IdentityServer website is shown.

For user experience you can use the client_id and acr_values for additional parameters to customize the login page on IdentityServer.




回答2:


Reading from the documentation it's sufficient to have an API call to the server. On the server side there will be a back-end running developed using the IdentityServer framework, this will handle the login / registration API calls.

As reference implementation you can have a look on the official demo and inspect the Network calls.



来源:https://stackoverflow.com/questions/59413043/user-authentication-through-api-using-identityserver4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!