user3676604
user3676604

Reputation:

Symfony http basic auth only for non authenticated users

in a symfony application we have preview domains for our clients. they start with client. if the client is logged in they should not have to enter http basic auth credentials.

So what i want to achieve is:

This is my configuration:

  providers:
    preview_users:
       memory:
          users:
            'client':
              password: 'mypass'
              roles: ROLE_PREVIEWER
  firewalls:
    preview_domain:
      provider: preview_users
      host: ^client-\d+
      http_basic:
        realm: "Client Preview"

  encoders:
   "Symfony\Component\Security\Core\User\User": plaintext

  access_control:
   - { host: ^client-\d+, roles: ROLE_PREVIEWER } 

what am i missing?

Upvotes: 3

Views: 973

Answers (1)

takeit
takeit

Reputation: 4081

Remove single quotes from 'client' and it will work, the rest of your configuration looks good.

Valid configuration for your provider should be:

  providers:
    preview_users:
      memory:
        users:
          client:
            password: 'mypass'
            roles: ROLE_PREVIEWER

See documentation for more details.

Upvotes: 1

Related Questions