Authentication using OAuth in Web API

2019-04-04 05:46发布

I'm working on a project using ASP.Net MVC5 which also includes a Web API. The API will be for internal use only. I'm using the OWIN library to provider authentication.

I'm having a difficult time figuring out how to correctly implement authentication through the API. I was planning on using OAuth 2.0 but the problem with OAuth is that the user needs to login through a browser page instead of a native login screen. So I was wondering if it is possible to somehow skip the browser.

I've found this example which creates it's own OAuth Authorization Server. But it doesn't show how to make the login native.

3条回答
Melony?
2楼-- · 2019-04-04 05:52

You could use Thinktecture.IdentityServer v2 as a light-weight security token service.

https://github.com/thinktecture/Thinktecture.IdentityServer.v2

查看更多
Summer. ? 凉城
3楼-- · 2019-04-04 06:12

You will need to create a WOPI host, which is basically a software solution that can take advantage of the browser-based Office(office web).

Create a custom WOPI host and configure it to use Office Web Apps Server to provide the browser-based file viewing and editing for Office files.

Nice sample on Microsoft MSDN

查看更多
一纸荒年 Trace。
4楼-- · 2019-04-04 06:13

If it's a highly trusted client, then you can use the OAuth2 resource owner password flow. You can look at the VS2013 SPA template and/or read on this post:

http://leastprivilege.com/2013/11/13/embedding-a-simple-usernamepassword-authorization-server-in-web-api-v2/

查看更多
登录 后发表回答