asp.net – 使用Active Directory的REST API的授权方法

使用以下要求确保REST Web API的最佳方法是什么?该系统具有在ASP.net中实现的REST API的Angular JS前端.

>系统中有两个“角色”,用户将有一个
角色.一个角色应允许访问一些API(称为“VIEW”),
一个角色允许访问其他API
>所有用户都在Active Directory中,所以如果我有一个用户名,我可以检查他们是什么角色有些客户端在Windows的盒子上,其他的在Linux
>我想保留会话,所以我不必为每个API调用查找AD
>我想单身登录.在Windows机器上,我不需要他们输入用户并通过,因为我已经可以使用Windows身份验证检索用户名.

我相信奥哈特是我最好的选择.

解决方法

There are two “roles” in the system,users will have one of the roles.
One role should allows access to some APIs (call it “VIEW”),the other
role allows access to other APIs

>对于基于角色的身份验证,您可以使用[Authorize(“Role”=“Manager”)].令牌将由身份服务器提供,并将声明包含为角色.

All users are in Active Directory,so if I have a username,I can
check what role they are in- Some clients are on Windows Boxes,the
others are on Linux

>如果您有ADFS,那么您可以拥有一个信任ADFS的身份服务器. ADFS将提供一个令牌,它将具有对角色的声明,并且您的Identity Server将进行声明转换,并将相同的角色声明返回到角度应用程序.

I would like to persist the session so I don’t have to look up AD for
every API call

>在请求令牌时,您可以要求离线范围,以便身份服务器将提供具有访问令牌的刷新令牌,以便您不需要一次又一次地要求AD.

I would like single sign on. On the Windows machines,I don’t require
them to enter user and pass as I already can retrieve their username
using Windows Authentication.

>对于这一个,您可以让您的Identity Server信任Windows身份验证的WSFederation.

因此,基本上您需要设置身份服务器,该服务器将为您提供令牌,REST API将使用该令牌来验证声明以将正确的信息返回给用户.

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....