Skip to content

Avoiding authentication on every request with Guard #9860

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

Merged
merged 0 commits into from
Jun 11, 2018
Merged

Avoiding authentication on every request with Guard #9860

merged 0 commits into from
Jun 11, 2018

Conversation

weaverryan
Copy link
Member

Hi guys!

See symfony/symfony#27395 and symfony/symfony#27427

When we're happy with this, I can merge and handle the changes on 3.4, because it will be almost entirely different (with supports(), autowiring & the Security class - booya for progress!)

If you create a Guard login system that's used by a browser and you're experiencing
problems with your session or CSRF tokens, the cause could be bad behavior by your
authenticator. When a Guard authenticator is meant to be used by a browser, you
should *not* authenticate the user on *every* request. On other words, you need to
Copy link
Member

Choose a reason for hiding this comment

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

"In other words"?

}
}

You'll also need to update your service configuration to ass the token storage:
Copy link
Member

Choose a reason for hiding this comment

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

typo: pass

@fabpot
Copy link
Member

fabpot commented May 31, 2018

Looks good to me, very clear and easy to understand.

@javiereguiluz
Copy link
Member

@weaverryan just asking: is this also related to this old pending issue? #5534

@weaverryan
Copy link
Member Author

Hmm, it's not unfortunately :/

Let's merge this PR once the code PR's are merged, as this PR mentions changing your firewall to "stateless" to avoid this issue, which isn't actually true yet in the code.

fabpot added a commit to symfony/symfony that referenced this pull request Jun 10, 2018
This PR was squashed before being merged into the 2.8 branch (closes #27452).

Discussion
----------

Avoid migration on stateless firewalls

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | Related to #27395
| License       | MIT
| Doc PR        | symfony/symfony-docs#9860

This is a proof-of-concept. Once we agree / are happy, I need to add this to all of the other authentication mechanisms that recently got the session migration code & add tests.

Basically, this avoids migrating the session if the firewall is stateless. There were 2 options to do this:

A) Make the `SessionAuthenticationStrategy` aware of all stateless firewalls. **This is the current approach**
or
B) Make each individual authentication listener aware whether or not *its* firewall is stateless.

Commits
-------

cca73bb Avoid migration on stateless firewalls
symfony-splitter pushed a commit to symfony/security-guard that referenced this pull request Jun 10, 2018
This PR was squashed before being merged into the 2.8 branch (closes #27452).

Discussion
----------

Avoid migration on stateless firewalls

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | Related to #27395
| License       | MIT
| Doc PR        | symfony/symfony-docs#9860

This is a proof-of-concept. Once we agree / are happy, I need to add this to all of the other authentication mechanisms that recently got the session migration code & add tests.

Basically, this avoids migrating the session if the firewall is stateless. There were 2 options to do this:

A) Make the `SessionAuthenticationStrategy` aware of all stateless firewalls. **This is the current approach**
or
B) Make each individual authentication listener aware whether or not *its* firewall is stateless.

Commits
-------

cca73bb564 Avoid migration on stateless firewalls
symfony-splitter pushed a commit to symfony/security that referenced this pull request Jun 10, 2018
This PR was squashed before being merged into the 2.8 branch (closes #27452).

Discussion
----------

Avoid migration on stateless firewalls

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | Related to #27395
| License       | MIT
| Doc PR        | symfony/symfony-docs#9860

This is a proof-of-concept. Once we agree / are happy, I need to add this to all of the other authentication mechanisms that recently got the session migration code & add tests.

Basically, this avoids migrating the session if the firewall is stateless. There were 2 options to do this:

A) Make the `SessionAuthenticationStrategy` aware of all stateless firewalls. **This is the current approach**
or
B) Make each individual authentication listener aware whether or not *its* firewall is stateless.

Commits
-------

cca73bb564 Avoid migration on stateless firewalls
symfony-splitter pushed a commit to symfony/security-http that referenced this pull request Jun 10, 2018
This PR was squashed before being merged into the 2.8 branch (closes #27452).

Discussion
----------

Avoid migration on stateless firewalls

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | Related to #27395
| License       | MIT
| Doc PR        | symfony/symfony-docs#9860

This is a proof-of-concept. Once we agree / are happy, I need to add this to all of the other authentication mechanisms that recently got the session migration code & add tests.

Basically, this avoids migrating the session if the firewall is stateless. There were 2 options to do this:

A) Make the `SessionAuthenticationStrategy` aware of all stateless firewalls. **This is the current approach**
or
B) Make each individual authentication listener aware whether or not *its* firewall is stateless.

Commits
-------

cca73bb564 Avoid migration on stateless firewalls
fabpot added a commit to symfony/symfony that referenced this pull request Jun 10, 2018
…PasswordJsonAuthenticationListener (weaverryan)

This PR was squashed before being merged into the 3.4 branch (closes #27556).

Discussion
----------

Avoiding session migration for stateless firewall UsernamePasswordJsonAuthenticationListener

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | Related to #27395
| License       | MIT
| Doc PR        | symfony/symfony-docs#9860

This is the sister PR to #27452, which covered all the other authentication listeners.

Commits
-------

c06f322 Avoiding session migration for stateless firewall UsernamePasswordJsonAuthenticationListener
@weaverryan weaverryan closed this Jun 11, 2018
@weaverryan weaverryan merged commit d2f062a into symfony:2.8 Jun 11, 2018
weaverryan added a commit that referenced this pull request Jun 11, 2018
…averryan)

This PR was squashed before being merged into the 2.8 branch (closes #9860).

Discussion
----------

Avoiding authentication on every request with Guard

Hi guys!

See symfony/symfony#27395 and symfony/symfony#27427

When we're happy with this, I can merge and handle the changes on 3.4, because it will be almost entirely different (with `supports()`, autowiring & the `Security` class - booya for progress!)

Commits
-------

d2f062a Avoiding authentication on every request with Guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants