小编Sim*_*ode的帖子

Identity Server 4:向访问令牌添加声明

我正在使用Identity Server 4和Implicit Flow,并且想要向访问令牌添加一些声明,新的声明或属性是"tenantId"和"langId".

我已将langId添加为我的范围之一,如下所示,然后通过身份服务器请求,但我也获得了tenantId.怎么会发生这种情况?

这是范围列表和客户端配置:

  public IEnumerable<Scope> GetScopes()
    {
        return new List<Scope>
        {
             // standard OpenID Connect scopes
            StandardScopes.OpenId,
            StandardScopes.ProfileAlwaysInclude,
            StandardScopes.EmailAlwaysInclude,

            new Scope
            {
                Name="langId",
                 Description = "Language",
                Type= ScopeType.Resource,
                Claims = new List<ScopeClaim>()
                {
                    new ScopeClaim("langId", true)
                }
            },
            new Scope
            {
                Name = "resourceAPIs",
                Description = "Resource APIs",
                Type= ScopeType.Resource
            },
            new Scope
            {
                Name = "security_api",
                Description = "Security APIs",
                Type= ScopeType.Resource
            },
        };
    }
Run Code Online (Sandbox Code Playgroud)

客户:

  return new List<Client>
        {
            new Client
            {
                ClientName = "angular2client", …
Run Code Online (Sandbox Code Playgroud)

c# jwt thinktecture-ident-server openid-connect identityserver4

20
推荐指数
3
解决办法
3万
查看次数

如何在ASP.Net核心中注入WCF服务客户端?

我有需要从ASP.NET Core访问的WCF服务.我已经安装了WCF Connected Preview并成功创建了代理.

它创建了接口和客户端,如下所示

    [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "0.3.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference1.IDocumentIntegration")]
    public interface IDocumentIntegration
    {

        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IDocumentIntegration/SubmitDocument", ReplyAction="http://tempuri.org/IDocumentIntegration/SubmitDocumentResponse")]
        [System.ServiceModel.FaultContractAttribute(typeof(ServiceReference1.FaultDetail), Action="http://tempuri.org/IDocumentIntegration/SubmitDocumentFaultDetailFault", Name="FaultDetail", Namespace="http://schemas.datacontract.org/2004/07/MyCompany.Framework.Wcf")]
        System.Threading.Tasks.Task<string> SubmitDocumentAsync(string documentXml);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "0.3.0.0")]
    public interface IDocumentIntegrationChannel : ServiceReference1.IDocumentIntegration, System.ServiceModel.IClientChannel
    {
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "0.3.0.0")]
    public partial class DocumentIntegrationClient : System.ServiceModel.ClientBase<ServiceReference1.IDocumentIntegration>, ServiceReference1.IDocumentIntegration
    { 
      // constructors and methods here
    }
Run Code Online (Sandbox Code Playgroud)

调用该服务的消费者类如下所示

public class Consumer
{
  private IDocumentIntegration _client;
  public Consumer(IDocumentIntegration client)
  {
    _client = client;
  }

  public async Task Process(string id)
  {  
     await _client.SubmitDocumentAsync(id);
  }
} 
Run Code Online (Sandbox Code Playgroud)

如何在Startup类中使用ConfigureServices方法注册IDocumentIntegration?我想在注册期间设置RemoteAddress和clientCredentials

  public void …
Run Code Online (Sandbox Code Playgroud)

c# .net-core coreclr asp.net-core

9
推荐指数
1
解决办法
1万
查看次数

了解 ElasticSearch 中的衰减函数及其参数

我正在阅读有关 ElasticSarch 中的衰减函数的信息,以宣传最近的结果

如果我定义衰减函数如下:

"DECAY_FUNCTION": { 
"FIELD_NAME": { 
"origin": "2013-09-17", 
"scale": "10d", 
"offset": "5d", 
"decay" : 0.5 
 } 
}
Run Code Online (Sandbox Code Playgroud)

在 Offset 、 Scale 区域内和它们之外的分数将如何受到影响?

gaussian elasticsearch

5
推荐指数
1
解决办法
3256
查看次数

如何在资源api中使用IdentityServer4范围

我在我的identityserver应用程序中创建了一个api资源:

new ApiResource
{
    Name = "socialnetwork",

    Scopes =
    {
        new Scope()
        {
            Name = "socialnetwork.read_contents",
            DisplayName = "Read"
        },
        new Scope
        {
            Name = "socialnetwork.share_content",
            DisplayName = "Write"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我如何在我的socialnetwork api控制器中使用这个范围.

public class SocialController : Controller
{
   [HttpGet]
   public async Task<IActionResult> GetCotntents(){

   }

   [HttpPost]       
   public async Task<IActionResult> ShareCotntents(string content){

   }
}
Run Code Online (Sandbox Code Playgroud)
  • 如果客户端具有socialnetwork.read_contents范围,则可以访问GetCotntents()方法.
  • 如果客户端具有socialnetwork.share_content范围,则可以访问ShareCotntents()方法.

实际上范围的目的是这个吗?我该如何使用它?

c# identityserver4

5
推荐指数
1
解决办法
1187
查看次数

如何在基于DDD的应用程序中实现检出?

首先,让我们说一个电子商务网站上有两个独立的汇总购物订单

Basket聚合有两个实体Basket(这是聚合根)和BaskItem定义如下(为简单起见,我删除了工厂和其他聚合方法):

public class Basket : BaseEntity, IAggregateRoot
{
    public int Id { get; set; }

    public string BuyerId { get; private set; }

    private readonly List<BasketItem> items = new List<BasketItem>();

    public  IReadOnlyCollection<BasketItem> Items
    {
            get
            {
                return items.AsReadOnly();
            }
     }

}

public class BasketItem : BaseEntity
{
    public int Id { get; set; }

    public decimal UnitPrice { get; private set; }

    public int Quantity { get; private set; } …
Run Code Online (Sandbox Code Playgroud)

c# domain-driven-design eventual-consistency aggregateroot

5
推荐指数
1
解决办法
307
查看次数

System.Web.Optimization缩小箭头功能问题

我有 js 文件,我正在使用箭头函数,如下所示:

$(document).ready(() => {});
Run Code Online (Sandbox Code Playgroud)

我正在使用System.Web.Optimization在 MVC Web 应用程序中进行捆绑和缩小。

当我运行我的应用程序时,它显示以下错误:

(9,20-21): 运行时错误 js1195: 预期表达式: )

那么,我的问题是有什么方法可以配置我的应用程序来解决这个问题?

asp.net-mvc bundling-and-minification system.web.optimization

5
推荐指数
0
解决办法
1078
查看次数

在 asp.net MVC web 应用程序中捆绑和缩小 ES6 javascript 文件

我们知道System.Web.optimization不支持 ES6 javascript 文件的打包和压缩,那么如何支持呢?

c# asp.net asp.net-mvc bundling-and-minification system.web.optimization

5
推荐指数
1
解决办法
1107
查看次数

使用FCM与Asp.net web api 2

我已经构建了一个web api,它将成为AngularJs,IOSAndroid前端应用程序的后端.

现在我需要在例如产品更新时将通知从我的web api推送到前端应用程序.

我正在考虑使用SignalR以实时方式推送通知,但如果其他用户处于脱机状态则无用.

现在我打算使用FCM推送通知,所以你可以请你回答我的问题

如何将我的web api与FCM集成,以及在推送通知时使用FCM可以获得哪些好处?

PS

我将不胜感激任何将asp.net web api与FCM集成的参考资料

c# push-notification asp.net-web-api firebase-cloud-messaging

4
推荐指数
1
解决办法
2967
查看次数

如何使用Nest ElasticSearch在多个索引中进行搜索?

我有两个具有以下映射的索引(我将简化它们的映射):

1)AccountType映射:

 elasticClient.CreateIndex("account", i => i
                .Settings(s => s
                          .NumberOfShards(2)
                          .NumberOfReplicas(0)
                          )
                          .Mappings(m => m
                                    .Map<AccountType>(map => map
                                               .AutoMap()
                                               .Properties(p => p
                                                    .Text(c => c
                                                           .Name(n => n.Name)
                                                           .Analyzer("standard")
                                                    )
                                                    .Text(c => c
                                                           .Name(n => n.Description)
                                                           .Analyzer("standard")
                                                    )
                                                )
                                    )
                            )
                          );
Run Code Online (Sandbox Code Playgroud)

2)ProductType映射:

 elasticClient.CreateIndex("proudct", i => i
                .Settings(s => s
                          .NumberOfShards(2)
                          .NumberOfReplicas(0)
                          )
                          .Mappings(m => m
                                    .Map<ProductType>(map => map
                                               .AutoMap()
                                               .Properties(p => p
                                                    .Text(c => c
                                                           .Name(n => n.Title)
                                                           .Analyzer("standard")
                                                    )
                                                    .Text(c => c
                                                           .Name(n => n.Description)
                                                           .Analyzer("standard")
                                                    )
                                                ) …
Run Code Online (Sandbox Code Playgroud)

elasticsearch nest

3
推荐指数
1
解决办法
1549
查看次数

添加时实体框架核心设置拥有的实体为空

我有以下图表:

public class Report
{
    public Guid Id { get; set; }
    public ICollection<EmployeeEntry> EmployeeEntries { get; set; }
}

public class EmployeeEntry
{
    public Guid Id { get; set; }
    public DateTimeOffset EntryDate { get; set; }
    public Address Address { get; set; }
}

public class Address
{
    public string City { get; set; }
    public string State { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

并使用 fluentApi 我已将地址配置为实体拥有的实体,EmployeeEntry如下所示:

private void ConfigureEmployeeEntry(EntityTypeBuilder<EmployeeEntry> builder)
{
    builder.OwnsOne(x => x.Address, w => …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core

3
推荐指数
1
解决办法
1679
查看次数