我正在开发一个symfony4 webapp。用户帐户存储在可通过API访问的数据库中。
我想实现此UserProviderInterface,如symfony4文档所建议,要使用symfony4安全模块功能。
据我了解,实现此接口需要API(或服务或db ...)返回将由symfony安全检查的数据(例如,哈希密码/ salt)。
有没有一种方法可以使用symfony安全模块而无需从用户提供程序获取此类数据?
例如,将用户以登录形式输入的用户名和密码发送到api,该用户名和密码将检查是否正确并返回布尔值?
您可以实现自己的Guard Authenticator来手动执行身份验证检查。
文档章节中描述了一个很好的示例实现:
配置示例如下所示:
security:
firewalls:
firewall_api:
pattern: '^/(.*)+$'
host: '^api\.mypage\.com$'
stateless: true
anonymous: false
guard:
# list of authenticators to try
authenticators:
- 'My\Bridge\Symfony\Security\Authenticator\Guard\JWTTokenAuthenticator'
- 'My\Bridge\Symfony\Security\Authenticator\Guard\FacebookAuthenticator'
# This authenticator's start() method is called
entry_point: 'My\Bridge\Symfony\Security\Authenticator\Guard\JWTTokenAuthenticator'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句