WebAPI OAuth Logout - How to drop Token Cookie?

前端 未结 2 994
深忆病人
深忆病人 2021-01-24 06:21

I have a WebAPI with OAuth login configured like this:

app.UseOpenIdConnectAuthentication(
    new OpenIdConnectAuthenticationOptions
    {
        ClientId = cl         


        
2条回答
  •  臣服心动
    2021-01-24 06:28

    You can't logout of the API because you're not logged in to it!

    For example, say your API uses Facebook as its OpenID authentication provider. Your user will have to log into facebook to use your API. Your API will redirect them to facebook auth server and if they are not logged in - facebook will ask them to log in.

    If the user decides to stay logged into facebook, then each time they use your API, they will not be required to login to facebook again and your middleware code will obtain a valid token for them to access your API.

    Your API can't remove the browser cookie between facebook and your user's browser so you can't log them out of facebook, so you can't stop them getting new tokens when they want.

    I don't know what OpenID provider you use but I would think the above applies for any.

    You can log out of MVC app as it would have created a cookie between you (user agent) and the MVC app when you logged in. It can delete its own cookie!

提交回复
热议问题