我已经登录到主域。说example.com(在旧版 kohana 中开发的应用程序)。我正在尝试登录 subdmain,比如foo.bar.example.com。
foo.example.com 是 symfony 应用程序。下面是我的配置。开发工具栏显示“匿名”用户。它不会从 cookie 中的会话 ID 登录用户。
安全.yml
# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
in_memory:
memory: ~
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
# activate different ways to authenticate
# http_basic: ~
# http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate
# form_login: ~
# http://symfony.com/doc/current/cookbook/security/form_login_setup.html
配置.yml
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: %trusted_proxies%
session:
# handler_id set to null will use default session handler from php.ini
handler_id: 'snc_redis.session.handler'
name: 'MY_COOKIE_NAME'
cookie_domain: '.example.com'
fragments: ~
http_method_override: true
request:
formats:
pdf: 'application/pdf'
epub: 'application/epub+zip'
snc_redis:
session:
client: session
prefix: ''
clients:
default:
type: predis
alias: default
dsn: %redis_dsn%
logging: false
options:
# profile: 2.6
profile: 2.2
connection_persistent: false
slave:
type: predis
alias: slave
logging: false
dsn: %redis_dsn_slave%
session:
type: predis
alias: session
dsn: %redis_dsn%
我是否需要配置至少一个身份验证提供程序?或者我需要编写自定义身份验证提供程序,就像记住我一样?
Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener->handle
有
if ($this->options['require_previous_session'] && !$request->hasPreviousSession()) {
throw new SessionUnavailableException('Your session has timed out, or you have disabled cookies.');
}
并且请求有
public function hasPreviousSession()
{
// the check for $this->session avoids malicious users trying to fake a session cookie with proper name
return $this->hasSession() && $this->cookies->has($this->session->getName());
}