ASP.NETCore-在VisualStudio2022中,授权重定向到相同的URL而不是IdentityServer的URL
创始人
2024-09-17 08:30:39
0

该问题可能是由Identity Server的配置不正确所引起的。您可以尝试按照以下步骤来解决此问题:

  1. 在您的应用程序的appsettings.json文件中,确保配置正确的Identity Server地址和客户端ID:
"Authentication": {
  "Scheme": "Cookies",
  "AutomaticAuthenticate": true,
  "AutomaticChallenge": true,
  "CookieName": "AuthCookie",
  "Events": {
    "OnRedirectToIdentityProvider": async context =>
    {
      context.ProtocolMessage.RedirectUri = 
        $"{context.Request.Scheme}://{context.Request.Host}{context.Request.PathBase}{context.Request.Path}";
    }
  },
  "OpenIdConnect": {
    "Authority": "https://identityserver.example.com",
    "ClientId": "your_client_id",
    "Scope": ["openid", "profile", "email"],
    "ResponseType": "code id_token",
    "GetClaimsFromUserInfoEndpoint": true,
    "SignInScheme": "Cookies",
    "SaveTokens": true,
    "UseTokenLifetime": false,
    "ClientSecret": "your_client_secret",
    "CallbackPath": "/signin-oidc",
    "SignedOutCallbackPath": "/signout-callback-oidc",
    "RemoteSignOutPath": "/signout-oidc",
    "RequireHttpsMetadata": true
  }
}
  1. 在startup.cs文件的ConfigureServices方法中,确保启用了授权和Identity Server:
public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddAuthorization();

    services.AddAuthentication(options =>
        {
            options.DefaultScheme = "cookies";
            options.DefaultChallengeScheme = "oidc";
        })
        .AddCookie("cookies")
        .AddOpenIdConnect("oidc", options =>
        {
            options.Authority = "https://identityserver.example.com";
            options.ClientId = "your_client_id";
            options.ClientSecret = "your_client_secret";
            options.ResponseType = "code id_token";
            options.Scope.Add("openid");
            options.Scope.Add("profile");
            options.Scope.Add("email");
            options.SaveTokens = true;
            options.Events

相关内容

热门资讯

德州ai机器人!德扑快速计算胜... 德州ai机器人!德扑快速计算胜率,德州之星app有,解说技巧(有挂详情)是一款可以让一直输的玩家,快...
aapoker挂!德扑之星系统... aapoker挂!德扑之星系统有哪里规律,wopoker透明挂,黑科技教程(有挂方法)是一款可以让一...
微扑克辅助器ios!微扑克规律... 微扑克辅助器ios!微扑克规律,wpk外挂被实锤,技巧教程(有挂教程)1、超多福利:超高返利,海量正...
wpk有外挂!德扑之星真的有辅... 您好,wpk有外挂这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这款...
德扑ai助手!pokermas... 德扑ai助手!pokermaster有德州吗,德扑线上创建房间,透视教程(有挂介绍);人气非常高,a...
wepokeai机器人!wpk... wepokeai机器人!wpk德州ai辅助神器,wpk德州职业代打,新版2025教程(有挂方法);致...
德州ai人工智能!aapoke... 德州ai人工智能!aapoker辅助工具下载,wpk发牌,必备教程(有挂技巧);无聊就玩这款德州ai...
wepoke辅助插件!微扑克系... wepoke辅助插件!微扑克系统发牌规律,We辅poker助,攻略教程(有挂教程)1、这是跨平台的微...
wepoke智能ai!德扑之星... wepoke智能ai!德扑之星怎么设置埋牌,微扑克俱乐部设置,第三方教程(有挂黑科技)1)wepok...
wepokeai机器人!aap... wepokeai机器人!aapoker在哪里下载,wepoke辅助软件下载,解密教程(有挂总结)是一...