This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Security/Http/Tests
Fabien Potencier fc6ed5bee3 feature #15141 [DX] [Security] Renamed Token#getKey() to getSecret() (WouterJ)
This PR was squashed before being merged into the 2.8 branch (closes #15141).

Discussion
----------

[DX] [Security] Renamed Token#getKey() to getSecret()

There are 2 very vague parameter names in the authentication process: `$providerKey` and `$key`. Some tokens/providers have the first one, some tokens/providers the second one and some both. An overview:

| Token | `providerKey` | `key`
| --- | --- | ---
| `AnonymousToken` | - | yes
| `PreAuth...Token` | yes | -
| `RememberMeToken` | yes | yes
| `UsernamePasswordToken` | yes | -

Both names are extremely general and their PHPdocs contains pure no-shit-sherlock-descriptions :squirrel: (like "The key."). This made me and @iltar think it's just an inconsistency and they have the same meaning.
...until we dived deeper into the code and came to the conclusion that `$key` has a Security task (while `$providerKey` doesn't really). If it takes people connected to Symfony internals 30+ minutes to find this out, it should be considered for an improvement imo.

So here is our suggestion: **Rename `$key` to `$secret`**. This explains much better what the value of the string has to be (for instance, it's important that the string is not easily guessable and cannot be found out, according to the Spring docs). It also explains the usage better (it's used as a replacement for credentials and to hash the RememberMeToken).

**Tl;dr**: `$key` and `$providerKey` are too general names, let's improve DX by renaming them. This PR tackles `$key` by renaming it to `$secret`.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

*My excuse for the completely unrelated branch name*

Commits
-------

24e0eb6 [DX] [Security] Renamed Token#getKey() to getSecret()
2015-07-02 01:04:20 +02:00
..
Authentication Merge branch '2.6' into 2.7 2015-05-15 15:33:16 +02:00
EntryPoint Merge branch '2.3' into 2.4 2014-09-22 10:51:05 +02:00
Firewall feature #15141 [DX] [Security] Renamed Token#getKey() to getSecret() (WouterJ) 2015-07-02 01:04:20 +02:00
Logout Merge branch '2.3' into 2.5 2014-12-30 10:03:46 +01:00
RememberMe [DX] [Security] Renamed Token#getKey() to getSecret() 2015-07-02 01:04:13 +02:00
Session Merge branch '2.3' into 2.5 2015-01-07 13:26:05 +01:00
AccessMapTest.php [Security] Split the component into 3 sub-components Core, ACL, HTTP 2013-09-18 09:16:41 +02:00
FirewallMapTest.php [Security] Split the component into 3 sub-components Core, ACL, HTTP 2013-09-18 09:16:41 +02:00
FirewallTest.php Merge branch '2.3' into 2.4 2014-09-22 10:51:05 +02:00
HttpUtilsTest.php [DX] Moved constants to a final class 2014-09-29 09:38:25 +02:00