【发布时间】:2015-11-09 09:53:38
【问题描述】:
我一直在试验 jhipster。 我已将我的应用程序配置为使用 oauth2。 为此,我的 application.yml 中有一个客户端密码
根据我找到的有关此主题的几篇文章,客户端机密应始终保密。例如检查https://aaronparecki.com/articles/2012/07/29/1/oauth2-simplified
客户机密必须保密。如果已部署的应用程序(例如 Javascript 或本机应用程序)无法对机密进行保密,则不会使用机密。
我注意到生成的 auth.oauth2.service.js 包含纯文本的秘密:
return {
login: function(credentials) {
var data = "username=" + credentials.username + "&password="
+ credentials.password + "&grant_type=password&scope=read%20write&" +
"client_secret=mySecretOAuthSecret&client_id=myapp";
return $http.post('oauth/token', data, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
"Authorization": "Basic " + Base64.encode("myapp" + ':' + "mySecretOAuthSecret")
}
}).success(function (response) {
var expiredAt = new Date();
expiredAt.setSeconds(expiredAt.getSeconds() + response.expires_in);
response.expires_at = expiredAt.getTime();
localStorageService.set('token', response);
return response;
});
},
我知道在缩小的 javascript 中找到它会有点困难,但是任何寻找“client_secret”的人都会很快得到回报。
我错过了什么吗?还是 jHipster oauth 实现不安全?
谢谢, 安迪
【问题讨论】: