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
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
..
Asset Merge branch '2.7' into 2.8 2015-05-12 17:16:46 +02:00
BrowserKit Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
ClassLoader Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
Config Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
Console Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
CssSelector Merge branch '2.7' into 2.8 2015-05-15 16:11:12 +02:00
Debug Towards 100% HHVM compat 2015-06-30 15:39:12 +02:00
DependencyInjection Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
DomCrawler Merge branch '2.7' into 2.8 2015-06-04 22:21:09 +02:00
EventDispatcher Add "shared" flag and deprecate scopes concept 2015-06-24 12:32:32 -03:00
ExpressionLanguage Merge branch '2.7' into 2.8 2015-05-12 17:16:46 +02:00
Filesystem Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
Finder Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
Form Merge branch '2.7' into 2.8 2015-07-01 20:24:26 +02:00
HttpFoundation Merge branch '2.7' into 2.8 2015-07-01 20:24:26 +02:00
HttpKernel Merge branch '2.7' into 2.8 2015-06-19 17:09:14 +02:00
Intl Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
Locale Merge branch '2.7' into 2.8 2015-06-19 17:09:14 +02:00
OptionsResolver Merge branch '2.7' into 2.8 2015-06-19 17:09:14 +02:00
Process Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
PropertyAccess Merge branch '2.7' into 2.8 2015-06-18 18:14:27 +02:00
Routing Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
Security feature #15141 [DX] [Security] Renamed Token#getKey() to getSecret() (WouterJ) 2015-07-02 01:04:20 +02:00
Serializer Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
Stopwatch Merge branch '2.7' into 2.8 2015-07-01 20:24:26 +02:00
Templating Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
Translation Merge branch '2.7' into 2.8 2015-07-01 20:24:26 +02:00
Validator Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00
VarDumper [VarDumper] Fix tests for HHVM 2015-07-01 20:24:23 +02:00
Yaml Merge remote-tracking branch 'origin/2.7' into 2.8 2015-07-01 14:16:54 +00:00