我们正在开发新的企业级应用程序,并希望利用Azure Active Directory登录应用程序,以便我们不必创建另一组用户凭据.但是,我们对此应用程序的权限模型比通过AAD内部的组处理的更复杂.
我们的想法是,除了ASP.NET核心标识框架之外,我们还可以使用Azure Active Directory OAuth 2.0来强制用户通过Azure Active Directory进行身份验证,然后使用身份框架来处理授权/权限.
您可以使用Azure OpenId身份验证创建项目开箱即用,然后您可以使用Identity框架轻松地将Microsoft帐户身份验证(非AAD)添加到任何项目.但是没有内置的东西可以将AAD的OAuth添加到身份模型中.
在尝试破解这些方法以使它们像我需要的那样工作之后,我终于尝试了自己创建自己的解决方案并建立了类OAuthHandler和OAuthOptions类.
我在这条路线上遇到了很多问题,但设法解决了大部分问题.现在我到了一个点,我从端点获得一个令牌,但我的ClaimsIdentity似乎没有效果.然后,当重定向到ExternalLoginCallback时,我的SigninManager无法获取外部登录信息.
几乎肯定必须有一些我想念的简单但我似乎无法确定它是什么.
Startup.cs
services.AddAuthentication()
.AddAzureAd(options =>
{
options.ClientId = Configuration["AzureAd:ClientId"];
options.AuthorizationEndpoint = $"{Configuration["AzureAd:Instance"]}{Configuration["AzureAd:TenantId"]}/oauth2/authorize";
options.TokenEndpoint = $"{Configuration["AzureAd:Instance"]}{Configuration["AzureAd:TenantId"]}/oauth2/token";
options.UserInformationEndpoint = $"{Configuration["AzureAd:Instance"]}{Configuration["AzureAd:TenantId"]}/openid/userinfo";
options.Resource = Configuration["AzureAd:ClientId"];
options.ClientSecret = Configuration["AzureAd:ClientSecret"];
options.CallbackPath = Configuration["AzureAd:CallbackPath"];
});
Run Code Online (Sandbox Code Playgroud)
AzureADExtensions
namespace Microsoft.AspNetCore.Authentication.AzureAD
{
public static class AzureAdExtensions
{
public static AuthenticationBuilder AddAzureAd(this AuthenticationBuilder builder)
=> builder.AddAzureAd(_ => { });
public static AuthenticationBuilder AddAzureAd(this AuthenticationBuilder builder, Action<AzureAdOptions> configureOptions)
{
return …Run Code Online (Sandbox Code Playgroud) 当我尝试将文件保存到Azure Functions目录(D:\home\data\temp\response.pdf)中的Temp存储时,出现以下错误.为什么我不能写到这个目录?
mscorlib: Exception has been thrown by the target of an invocation. System: An exception occurred during a WebClient request. mscorlib: ***Could not find a part of the path 'D:\home\data\temp\response.pdf'.***
2017-09-19T07:05:24.353 Function completed (Failure, Id=3aa4b740-ba8a-465c-ad7c-75b38fa2a472, Duration=334ms)
2017-09-19T07:06:31 No new trace in the past 1 min(s).
Run Code Online (Sandbox Code Playgroud) web.config中的ipSecurity部分是否适用于Azure App Services?
使用托管在Azure上的Web应用程序设置简单IP地址阻止(黑名单)的步骤是什么?
这是F#中一个极其困难的问题,在C#中非常容易
我正在使用自定义DomainManager在F#中编写Azure移动应用程序表控制器.该DomainManager所继承MappedEntityDomainManager<,>,它采用Automapper在幕后来映射我的数据库对象转换成适合移动设备的记录.
Automapper配置文件如下所示:
type EventOrganiserProfile() =
inherit Profile()
do
let nullDateTime = Nullable<DateTime>()
base.CreateMap<MyDbEntity, MyMobileDto>()
...
.ForMember(fun dest -> dest.UpdatedAt, fun opt -> opt.MapFrom(fun src -> if src.CancelledUtc <> nullDateTime then src.CancelledUtc.Value else src.StartedUtc))
...
|> ignore
base.CreateMap<MyMobileDto, MyDbEntity>()
...
|> ignore
Run Code Online (Sandbox Code Playgroud)
src.StartedUtc是一个DateTime,src.CancelledUtc是一个可空的DateTime,因为它的类继承自的EntityData,dest.UpdatedAt是一个可空的DateTimeOffset.
此代码编译,但当我尝试运行它时,我收到错误消息
System.NotSupportedException:'LINQ to Entities无法识别方法'System.DateTime Invoke(System.Nullable`1 [System.DateTime])'方法,并且此方法无法转换为商店表达式.
这似乎指的是我对.Value财产的使用Nullable<DateTime>.根本原因是F#严格的类型检查.在C#中,这将由空合并运算符无缝处理??.
有没有办法模拟空合并作为F#中实体框架友好表达式的一部分?
昨天,我在Microsoft.Azure.Management.ResourceManager的1.5.0版预览中使用了这行代码:
var listResources =
ResourceManagementClient.ResourceGroups.ListResources(resourceGroup.Name);
Run Code Online (Sandbox Code Playgroud)
今天,我已经更新到1.6.0版预览版,但是这个功能似乎不再可用了.是否有其他方法可以获取资源组中包含的资源列表?
我有以下代码。
async function bulkInsert(db, collectionName, documents) {
try {
const cosmosResults = await db.collection(collectionName).insertMany(documents);
console.log(cosmosResults);
return cosmosResults
} catch (e) {
console.log(e)
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用大量文档来运行它,我会得到(并非意外)
{ MongoError: Message: {"Errors":["Request rate is large"]}
ActivityId: b3c83c38-0000-0000-0000-000000000000,
Request URI: /apps/DocDbApp/services/DocDbServer24/partitions/a4cb4964-38c8-11e6-8106-8cdcd42c33be/replicas/1p/,
RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.19.102.5
at G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\pool.js:596:61
at authenticateStragglers (G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\pool.js:514:16)
at Connection.messageHandler (G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\pool.js:550:5)
at emitMessageHandler (G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\connection.js:309:10)
at TLSSocket.<anonymous> (G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\connection.js:452:17)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
name: 'MongoError',
message: 'Message: {"Errors":["Request rate is large"]}\r\nActivityId: b3c83c38-0000-0000-0000-000000000000,
Request …Run Code Online (Sandbox Code Playgroud) 有没有办法在没有定义具体容器的情况下触发Azure功能?
我期待,下面的函数将被触发任何容器中的任何文件.文件和容器的名称应该是变量.
*****function.json:
{
"bindings": [
{
"type": "blobTrigger",
"name": "myBlob",
"path": "{container}/{name}",
"connection": "AzureWebJobsStorage",
"direction": "in"
}
],
"disabled": false
}
*****run.csx:
public static void Run(Stream myBlob, string name, string container, TraceWriter log, out string outputSbMsg)
{
log.Info("C# Blob trigger function Processed blob");
log.Info(name);
log.Info(container);
}
Run Code Online (Sandbox Code Playgroud)
但是,什么也没有触发.知道什么是错的吗?
我想将我的 azure sql db 移动到另一台主机。但是我的新主机只允许导入 sql db 备份文件 (.BAK);我发现了如何使用 SQL Server Management Studio 生成 .BACPAK 文件,但我找不到从我的 azure sql db 创建 BAK 文件的方法。请帮忙。
我正在向以下API发出GET请求
https://management.azure.com/subscriptions/{{subscriptionId}}/providers/Microsoft.Authorization/roleAssignments?api-version=2017-10-01-preview
Run Code Online (Sandbox Code Playgroud)
这给了我以下的响应格式
{
"properties": {
"roleDefinitionId": "/subscriptions/5a9c0639-4045-4c23-8418-fc091e8d1e31/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c",
"principalId": "fdef6f38-b48f-4358-8482-b243ea935082",
"principalType": "User",
"scope": "/subscriptions/5a9c0639-4045-4c23-8418-fc091e8d1e31/resourceGroups/GE-RGrp-Kentico",
"createdOn": "2017-08-21T11:38:53.7973201Z",
"updatedOn": "2017-08-21T11:38:53.7973201Z",
"createdBy": "f418e9e8-becc-41d8-ab47-66a4c50403b5",
"updatedBy": "f418e9e8-becc-41d8-ab47-66a4c50403b5"
},
"id": "/subscriptions/5a9c0639-4045-4c23-8418-fc091e8d1e31/resourceGroups/GE-RGrp-Kentico/providers/Microsoft.Authorization/roleAssignments/5e6caac9-c5fd-42f0-86c6-9e96b127be51",
"type": "Microsoft.Authorization/roleAssignments",
"name": "5e6caac9-c5fd-42f0-86c6-9e96b127be51"
}
Run Code Online (Sandbox Code Playgroud)
但是,当我执行CLI调用时,我会得到以下响应
> az role assignment list
{
"id": "/subscriptions/5a9c0639-4045-4c23-8418-fc091e8d1e31/providers/Microsoft.Authorization/roleAssignments/4096c146-b6f8-4f92-a700-a47742a5b321",
"name": "4096c146-b6f8-4f92-a700-a47742a5b321",
"properties": {
"additionalProperties": {
"createdBy": "c2024d65-cf17-45fd-b34b-09cd5c21cac7",
"createdOn": "2017-11-07T22:03:12.4998370Z",
"updatedBy": "c2024d65-cf17-45fd-b34b-09cd5c21cac7",
"updatedOn": "2017-11-07T22:03:12.4998370Z"
},
"principalId": "780925c0-a487-4529-9eb2-837aa67a4d8a",
"principalName": "xcavanap@genesisenergy.co.nz",
"roleDefinitionId": "/subscriptions/5a9c0639-4045-4c23-8418-fc091e8d1e31/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd",
"roleDefinitionName": "Security Admin",
"scope": "/subscriptions/5a9c0639-4045-4c23-8418-fc091e8d1e31"
},
Run Code Online (Sandbox Code Playgroud)
上面的回应确实有
"roleDefinitionName": "Security Admin"
但我希望通过API获得相同的响应,请帮助!!
我有一个在 Visual Studio 2017 中创建的 ASP.NET Web 应用程序。
在应用程序中有一个表单,用户可以在其中上传文件。上传文件后,我会处理它们并将它们保存在文件系统中:
var photo = Request.Files["file"];
photo.SaveAs("D:\\home");
Run Code Online (Sandbox Code Playgroud)
一切都在本地完美运行,但是当我在 Azure 应用服务上部署应用程序时它不起作用。
我读到,在 Azure 上,路径
D:\home
Run Code Online (Sandbox Code Playgroud)
应该是可写的。
但是当我尝试代码时,我收到此错误:
Access to the path 'd:\home\test_image.JPG' is denied.
Run Code Online (Sandbox Code Playgroud) azure ×9
c# ×2
api ×1
asp.net ×1
asp.net-core ×1
f# ×1
file-io ×1
iis ×1
ip ×1
javascript ×1
mongodb ×1
node.js ×1
oauth ×1
rbac ×1
sql-server ×1