키를 숨기는 방법에 대해 정말 고심하고 있습니다.Node.js 앱에 대한 내 비밀 키는 어디에 저장해야합니까?
내가 숨길 필요가있는 두 가지 키는 secrets.crypto 및 secrets.jwt입니다. Elastic Beanstalk을 사용하여 AWS에서 내 애플리케이션을 호스팅 할 계획입니다.
또한 내 Dynamodb 및 내 S3 버킷과 같은 항목에 액세스하기 위해 내 키를 어디에 둘 것인지 잘 모르겠습니다.
exports.generateToken = (type, user) => {
if (!_.isString(type)) {
return undefined;
}
try {
//Turn the json object of the current user's id and the type of token into a string
var stringData = JSON.stringify({
_id: user._id,
type: type
});
//Take the json string and encrypt it with a secret then turn it back into a string
var encryptedData = cryptojs.AES.encrypt(stringData, secrets.crypto).toString();
//Take the encryptedData and turn it into a token with a secret
var token = jwt.sign({
token: encryptedData
}, secrets.jwt);
return token;
} catch(e) {
return undefined;
}
};
안전한 방법인가 – ConnorB
'eb setenv' 호출은 SSL 연결을 통해 AWS API에 키 이름과 값을 전송하므로 값을 설정하는 안전한 방법입니다. 내가 믿는 AWS 웹 콘솔을 통해 동일한 작업을 수행 할 수도 있습니다. AWS 계정에 대한 액세스를 제한하는 한 "안전"합니다. 이 값들에 대해 더 많은 보안을 원한다면 AWS 키 관리 서비스 (KMS)를 사용할 수 있습니다. Elastic Beanstalk과 밀접하게 통합되어 있지 않으므로 응용 프로그램에 해당 서비스를 사용하기위한 몇 가지 지원을해야합니다. –