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 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏