douqiao8370 2017-04-07 09:45
浏览 25
已采纳

Symfony,如何在公共代码库中将in_memory提供者的凭证设为私有?

I setup a Symfony project to use some credential from an in_memory provider:

providers:
    in_memory:
        memory:
            users:
                user1:
                    password: password1
                    roles: 'ROLE1'

Now the code for this application is going to be released on github and I obviously want to keep the credentials private.

Is there a way to load this configurations from a different (non-versioned) file? I'm looking for a solution that allows me to edit the code as little as possible and, if possible, to avoid changing the security provider used.

  • 写回答

1条回答 默认 最新

  • dongren1011 2017-04-07 09:56
    关注

    You can define your password as Parameter

    In your security.yml :

    providers:
        in_memory:
            memory:
                users:
                    user1:
                        password: "%your_parameter_key%"
                        roles: 'ROLE1'
    

    In your parameters.yml :

    parameters:
        your_parameter_key: your_secret_password
    

    Usually, parameters.yml should be ignored by GIT.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置