Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide stronger guidance for using identity cookies over tokens for security #32994

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

halter73
Copy link
Member

@halter73 halter73 commented Jul 3, 2024

Copy link
Contributor

@tdykstra tdykstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I just left a suggestion to avoid future tense.

@@ -13,7 +13,7 @@ uid: security/authentication/identity/spa

:::moniker range=">= aspnetcore-8.0"

[ASP.NET Core Identity](xref:security/authentication/identity) provides APIs that handle authentication, authorization, and identity management. The APIs make it possible to secure endpoints of a Web API backend with cookie-based authentication. There's a token-based option for clients that can't use cookies.
[ASP.NET Core Identity](xref:security/authentication/identity) provides APIs that handle authentication, authorization, and identity management. The APIs make it possible to secure endpoints of a Web API backend with cookie-based authentication. There's a token-based option for clients that can't use cookies, but you must be careful not to leak tokens. We recommend using cookies in browser-based applications, because the browser will automatically handle them without exposing them to JavaScript by default.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[ASP.NET Core Identity](xref:security/authentication/identity) provides APIs that handle authentication, authorization, and identity management. The APIs make it possible to secure endpoints of a Web API backend with cookie-based authentication. There's a token-based option for clients that can't use cookies, but you must be careful not to leak tokens. We recommend using cookies in browser-based applications, because the browser will automatically handle them without exposing them to JavaScript by default.
[ASP.NET Core Identity](xref:security/authentication/identity) provides APIs that handle authentication, authorization, and identity management. The APIs make it possible to secure endpoints of a Web API backend with cookie-based authentication. There's a token-based option for clients that can't use cookies, but you must be careful not to leak tokens. We recommend using cookies in browser-based applications, because the browser automatically handles them without exposing them to JavaScript by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps even more forceful?

ASP.NET Core Identity provides APIs that handle authentication, authorization, and identity management. The APIs make it possible to secure endpoints of a Web API backend with cookie-based authentication. A token-based option is available for clients that can't use cookies, but in using this you are responsible for ensuring the tokens are kept secure. We recommend using cookies for browser-based applications, because, by default, the browser automatically handles them without exposing them to JavaScript.

@@ -202,7 +202,9 @@ Some web clients might not include cookies in the header by default:

## Use token-based authentication

For clients that don't support cookies, the login API provides a parameter to request tokens. A custom token (one that is proprietary to the ASP.NET Core identity platform) is issued that can be used to authenticate subsequent requests. The token is passed in the `Authorization` header as a bearer token. A refresh token is also provided. This token allows the application to request a new token when the old one expires without forcing the user to log in again.
For clients that don't support cookies, the login API provides a parameter to request tokens, but you must be careful not to leak tokens. We recommend using cookies in browser-based applications, because the browser will automatically handle them without exposing them to JavaScript by default.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For clients that don't support cookies, the login API provides a parameter to request tokens, but you must be careful not to leak tokens. We recommend using cookies in browser-based applications, because the browser will automatically handle them without exposing them to JavaScript by default.
For clients that don't support cookies, the login API provides a parameter to request tokens, but you must be careful not to leak tokens. We recommend using cookies in browser-based applications, because the browser automatically handles them without exposing them to JavaScript by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same sort of forcefulness as above, and swap around where by default lands.

We recommend using cookies in browser-based applications, because, by default the browser automatically handles them without exposing them to JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants