简体   繁体   English

从OS X Keychain获取值到Gruntfile

[英]Get Values into Gruntfile from OS X Keychain

In a Gruntfile, it's possible to load values from a JSON file using grunt.file.readJSON(...) . 在Gruntfile中,可以使用grunt.file.readJSON(...)从JSON文件加载值。 Is there a module, plugin, etc., that allows loading values from the OS X keychain? 是否有模块,插件等,允许从OS X钥匙串加载值?

I'm looking for a more secure way to store, eg, AWS credentials for use with Grunt than just some random JSON file that happens not to be committed to my git repo. 我正在寻找一种更安全的存储方式,例如,与Grunt一起使用的AWS凭证,而不仅仅是一些随机的JSON文件,它不会被提交给我的git repo。

I'm not sure if this is the best way, but I stumbled into using the keytar node module . 我不确定这是不是最好的方法,但我偶然发现了使用keytar节点模块 I added 我补充道

var keytar = require('keytar');

toward the top of my module.exports function in my Gruntfile, got the values of the properties I wanted read from the keychain like 在我的Gruntfile中,我的module.exports函数的顶部,得到了我想从钥匙串读取的属性的值,如

aws: {
    key: keytar.getPassword('AWS-S3-AccessKeyId', 'example.com'),
    secret: keytar.getPassword('AWS-S3-SecretAccessKey', 'example.com')
},

inside the grunt.initConfig({...}) call, and used the node REPL to set the values: grunt.initConfig({...})调用内部,并使用node REPL设置值:

keytar = require('keytar');
keytar.addPassword('AWS-S3-AccessKeyId', 'example.com', 'AccessKeyGoesHere')
keytar.addPassword('AWS-S3-SecretAccessKey', 'example.com', 'SuperSecretKeyHere')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM