Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[RFC] Add #[SensitiveParameter] attribute to password arguments across components #46853

Closed
@alexandre-daubois

Description

@alexandre-daubois

Description

A new attribute named #[SensitiveParameter] has been introduced in PHP 8.2 to prevent sensitive method arguments to leak in application logs, exceptions and backtraces. I think this would be great to add this attribute across the framework.

Here is the RFC: https://wiki.php.net/rfc/redact_parameters_in_back_traces
Human-readable RFC: https://php.watch/versions/8.2/backtrace-parameter-redaction
Here is the commit to php-src: php/php-src@9085197

I create this RFC to discuss if there is any contraindication to do this. You'll find a simple example below on how it would look like.

Example

Password credentials

namespace Symfony\Component\Security\Http\Authenticator\Passport\Credentials;

// ...

class PasswordCredentials implements CredentialsInterface
{
    // ...

    public function __construct(
        \[SensitiveParameter]
        string $password
    ) {
        $this->password = $password;
    }

    // ...
}

HttpOptions

namespace Symfony\Component\HttpClient;

// ...

class HttpOptions
{
    // ...

    public function setAuthBasic(
        string $user,
        #[\SensitiveParameter]
        string $password = ''
    ): static
    {
        $this->options['auth_basic'] = $user;

        if ('' !== $password) {
            $this->options['auth_basic'] .= ':'.$password;
        }

        return $this;
    }

    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions