小编las*_*ink的帖子

如何在 asp.net core 中为 JwtBearer 和 System.IdentityModel.Tokens.Jwt 自定义承载头关键字?

使用using Microsoft.AspNetCore.Authentication.JwtBearer;我一直无法弄清楚如何将标题中的“Bearer”键更改为其他内容,在这种情况下,我希望它是“Token”。

启动文件

services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x =>
             {
                 x.RequireHttpsMetadata = false;
                 x.SaveToken = true;
                 x.TokenValidationParameters = new TokenValidationParameters
                 {
                     ValidateIssuerSigningKey = true,
                     IssuerSigningKey = new SymmetricSecurityKey(key),
                     ValidateIssuer = false,
                     ValidateAudience = false,
                     ValidateLifetime = true,
                     ValidIssuer = Configuration.GetValue<string>("JwtIssuer"),
                     ValidAudience = Configuration.GetValue<string>("JwtAudience"),
                 };
                 x.Events = new JwtBearerEvents
                 {
                     OnAuthenticationFailed = context =>
                     {
                         if (context.Exception.GetType() == typeof(SecurityTokenExpiredException))
                         {
                             context.Response.Headers.Add("Token-Expired", "true");
                         }
                         return Task.CompletedTask;
                     }
                 };
             });
Run Code Online (Sandbox Code Playgroud)

当我做类似的事情时

GET {{protocol}}://{{url}}/users HTTP/1.1
Authorization: …
Run Code Online (Sandbox Code Playgroud)

c# bearer-token .net-core asp.net-core

6
推荐指数
1
解决办法
7081
查看次数

flutter 从外部打开文件,例如在 ios 上“打开”

据我所知,大多数 flutter 指南都可以从本地存储打开,但没有关于文件共享的信息。任何人都知道如何做到这一点。这是专门针对 ios 启用它的指南https://developer.apple.com/library/archive/qa/qa1587/_index.html

我的意思是有https://pub.dartlang.org/packages/open_file扩展名,但从文件存储中打开。

要澄清这个问题并不是要与另一个应用程序共享文件,而是当从外部应用程序共享时,系统会提示在此flutter应用程序中打开文件。

android external-application file ios flutter

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

如何让 MSSQL 服务容器在 Azure DevOps 管道中工作?

描述

我正在azure devops 管道中尝试用于集成数据库测试服务容器

根据这个开源的虚拟 ci cd 管道项目https://dev.azure.com/funktechno/_git/dotnet%20ci%20pipelines。我正在尝试使用 azure devops服务容器进行集成管道测试。我让 postgress 和 mysql 工作。我在使用microsoft sql server 时遇到问题。

.yml 文件

resources:
  containers:
  - container: mssql
    image: mcr.microsoft.com/mssql/server:2017-latest
    ports: 
      # - 1433
      - 1433:1433
    options: -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -e 'MSSQL_PID=Express'

- job: unit_test_db_mssql
  # condition: eq('${{ variables.runDbTests }}', 'true')
  # continueOnError: true
  pool:
    vmImage: 'ubuntu-latest'
  services:
    localhostsqlserver: mssql
  steps:
    - task: UseDotNet@2
      displayName: 'Use .NET Core sdk 2.2'
      inputs:
        packageType: sdk …
Run Code Online (Sandbox Code Playgroud)

sql-server automated-tests docker azure-devops azure-pipelines

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