Behandlung des abgelaufenen Zugriffstokens in asp.net core mithilfe des Aktualisierungstokens mit OpenId Connect

Ich habe einen ASOS OpenIdConnect-Server mit und eine asp.net-Kern-MVC-App konfiguriert, die "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0 und" Microsoft.AspNetCore.Authentication.Cookies ":" 1.0.0 "verwendet. Ich habe den Workflow "Autorisierungscode" getestet und alles funktioniert.

Die Client-Webanwendung verarbeitet die Authentifizierung wie erwartet und erstellt ein Cookie, in dem das ID_Token, das Access_Token und das Refresh_Token gespeichert werden.

Wie erzwinge ich, dass Microsoft.AspNetCore.Authentication.OpenIdConnect ein neues access_token anfordert, wenn es abläuft?

Die asp.net core mvc App ignoriert das abgelaufene access_token.

Ich möchte, dass openidconnect das abgelaufene access_token anzeigt und dann mit dem Aktualisierungstoken einen Anruf tätigt, um ein neues access_token abzurufen. Es sollte auch die Cookie-Werte aktualisieren. Wenn die Anforderung des Aktualisierungstokens fehlschlägt, würde ich erwarten, dass openidconnect das Cookie "abmeldet" (es oder etwas anderes entfernt).

app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AutomaticAuthenticate = true,
            AutomaticChallenge = true,
            AuthenticationScheme = "Cookies"
        });

app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
        {
            ClientId = "myClient",
            ClientSecret = "secret_secret_secret",
            PostLogoutRedirectUri = "http://localhost:27933/",
            RequireHttpsMetadata = false,
            GetClaimsFromUserInfoEndpoint = true,
            SaveTokens = true,
            ResponseType = OpenIdConnectResponseType.Code,
            AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet,
            Authority = http://localhost:27933,
            MetadataAddress = "http://localhost:27933/connect/config",
            Scope = { "email", "roles", "offline_access" },
        });

Antworten auf die Frage(4)

Ihre Antwort auf die Frage