小编Phi*_*use的帖子

如何将内存中的用户提供程序注入服务?

我正在关注http://symfony.com/doc/current/cookbook/security/voters.html并尝试制作一个自定义投票人,拒绝访问不包含有效API密钥和摘要的请求(受http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html影响- 我没有构建身份验证提供程序,因为我需要使用FOSUserBundle提供程序来处理相同的请求).

我想将我的api密钥/秘密存储在内存中的用户提供程序中,并且可能会在以后将其迁移到自定义mongodb提供程序.所以我需要一种方法将用户提供者注入我的选民.我已经注入了服务容器,但可以从中访问用户提供程序吗?

我的服务定义:

services:
    security.access.api_client_voter:
        class:     Acme\RestBundle\Security\Authorization\Voter\ApiClientVoter
        arguments: [@service_container, %kernel.cache_dir%/security/nonces]
        public:    false
        tags:
            - { name: monolog.logger, channel: authentication }
            - { name: security.voter }
Run Code Online (Sandbox Code Playgroud)

所以我的问题是,我如何注入内存提供商?食谱中的WSSE示例似乎使用auth提供程序工厂来替换字符串'security.providers.in_memory',但由于我只是使用选民,这是必要的吗?如果有必要,我的工厂会是什么样子?

php authentication service dependency-injection symfony

7
推荐指数
2
解决办法
1907
查看次数

javascript中对象的笛卡尔积

我需要根据N个属性列表生成一组完整的变体,同时保持属性名称不变.

var input = [
    { 'colour' : ['red', 'green'] },
    { 'material' : ['cotton', 'wool', 'silk'] },
    { 'shape' : ['round', 'square', 'rectangle'] }
];

var expected = [
    { 'colour': 'red', 'material': 'cotton', 'shape': 'round' },
    { 'colour': 'red', 'material': 'cotton', 'shape': 'square' },
    { 'colour': 'red', 'material': 'cotton', 'shape': 'rectangle' },
    { 'colour': 'red', 'material': 'wool', 'shape': 'round' },
    { 'colour': 'red', 'material': 'wool', 'shape': 'square' },
    { 'colour': 'red', 'material': 'wool', 'shape': 'rectangle' },
    { 'colour': …
Run Code Online (Sandbox Code Playgroud)

javascript set cartesian-product

6
推荐指数
1
解决办法
1146
查看次数

投票者导致500错误而不是403

我创建了一个自定义投票人,如果请求不包含有效的身份验证标头,则拒绝访问我的API.它基于两个食谱条目的组合:http: //symfony.com/doc/current/cookbook/security/voters.htmlhttp://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html

<?php

namespace Acme\RestBundle\Security\Authorization\Voter;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\NonceExpiredException;
use Monolog\Logger;

class ApiClientVoter implements VoterInterface
{
    protected $container;
    protected $nonceCacheDir;

    /**
     * We inject the full service container due to scope issues when
     * injecting the request.
     *
     * @param ContainerInterface $container
     * @param string $nonceCacheDir
     */
    public function __construct(ContainerInterface $container, $nonceCacheDir)
    {
        $this->container     = $container;
        $this->nonceCacheDir = $nonceCacheDir;
    }

    public function supportsAttribute($attribute)
    {
        // we won't check against a …
Run Code Online (Sandbox Code Playgroud)

php security response symfony

5
推荐指数
0
解决办法
1220
查看次数

phpstorm:更改当前搜索匹配的颜色

我想在搜索时更改当前匹配的颜色,因为我正在使用的方案(夜晚的热量)不能很好地突出(黑色为灰色).

Editor -> Colors & Fonts -> General修改"文本搜索结果"工作正常(除了第一个之外的所有匹配),但"搜索结果"和"搜索结果(写访问)"仅影响预览而不影响实际的编辑器窗口.

我需要更新一些其他设置吗?

ide themes phpstorm

4
推荐指数
1
解决办法
732
查看次数