我正在调查使用Stormpath进行用户管理.
我目前有一个使用Node.js/Express.js的Sails.js应用程序.目前,会话管理由默认的Sails.js框架处理,该框架严重依赖于Express的会话中间件.
会话存储在生产中的共享Redis数据库中,这样我们就可以使多个API服务器保持无状态.
我的问题是两个会话管理系统会发生冲突和/或导致错误吗?他们必须合并还是我们可以安全地将它们分开?如果必须合并,你如何配置中间件?
作为注释,我们不会在Stormpath上存储太多用户数据,我们只会将它们用作身份验证/令牌提供程序.
谢谢您的帮助!
我正在尝试使用jhipster.该样本开箱即用.
我想将其配置为使用Stormpath用户管理 - https://github.com/stormpath/stormpath-spring-security/wiki
我找不到任何关于确保Spring Server和AngularJS Client都使用StormPath的博客/文章.
我想在stormpath登录屏幕中禁用创建帐户.应该已经通过对应用程序进行身份验证的用户调用api.我尝试将stormpathEnableRegistration设置为false,但仍启用了注册功能.
app.use(stormpath.init(app, {
apiKeyFile: config.stormpathapi.apiKeyFile,
application: config.stormpathapi.application,
secretKey: config.stormpathapi.secretKey,
sessionDuration: 1000 * 60 * 30,
enableAutoLogin: true,
enableUsername: true,
stormpathEnableRegistration: false
}));
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在创建一个Spring Security配置,以供任何想要创建由Spring Security保护的Stormpath Spring应用程序的开发人员用作库.
对于我有子类WebSecurityConfigurerAdapter,定义了Stormpath访问控件configure(HttpSecurity)以及与Stormpath AuthenticationProvider借助于configure(AuthenticationManagerBuilder).所有这些都可以在这个抽象类及其具体的子类中看到:
@Order(99)
public abstract class AbstractStormpathWebSecurityConfiguration extends WebSecurityConfigurerAdapter {
//Removed properties and beans for the sake of keeping focus on the important stuff
/**
* The pre-defined Stormpath access control settings are defined here.
*
* @param http the {@link HttpSecurity} to be modified
* @throws Exception if an error occurs
*/
protected void configure(HttpSecurity http, AuthenticationSuccessHandler successHandler, LogoutHandler logoutHandler)
throws Exception {
if (loginEnabled) {
http
.formLogin() …Run Code Online (Sandbox Code Playgroud) 我有一个使用Stormpath中间件进行身份验证的应用程序设置.我还有我的帐户设置来使用每个组织模型的组.它似乎登录和一切,但我正在努力找到一个合理的方法来获取组织ID或名称基于登录的用户.
使用Stormpath.SDK.Account引用,我可以执行以下操作:
private readonly IAccount _account;
var name = _account.FullName;
Run Code Online (Sandbox Code Playgroud)
我希望有类似的东西可以检索组织,但我没有在他们的SDK参考中找到任何东西.到目前为止,我已经尝试过:
从我的索赔中检索组织.看起来它可以通过"onk"声明获得,但是当我从以下代码查看_claim的属性时,我没有看到它作为一个选项:
ClaimsPrincipal _claim = new ClaimsPrincipal(User.Identity);
var OrganizationId = _claim.FindFirst("onk").Value;
Run Code Online (Sandbox Code Playgroud)
我也没有看到从标题中检索组织的方法.这似乎是主机可用的头,但核心的SDK似乎并没有让我明白了.
理想情况下,我希望用户能够登录而不将其租户指定为子域或登录表单中的字段.由于它将按顺序通过我的组织商店,我希望这是可行的.
关于我缺少的任何想法?
我正在考虑使用Stormpath将它的Java API作为用户存储.
看起来不错,除了我无法搜索用户.
例如,我收到此错误:
Exception in thread "main" com.stormpath.sdk.resource.ResourceException: HTTP 400, Stormpath 2105 (http://docs.stormpath.com/errors/2105): Account ID is not a supported query property.
Run Code Online (Sandbox Code Playgroud)
当我执行此查询时:
HashMap<String, Object> queryParams = Maps.newHashMap();
queryParams.put("ID", "4mPXXXXXXXXXX");
searchResult = application.getAccounts(queryParams);
Run Code Online (Sandbox Code Playgroud)
然而,通过电子邮件搜索用户是有效的.当我尝试通过存储在customData属性中的登录令牌搜索用户时,我收到相同的错误.
看起来我想做的事情是不可能的,因为看起来你可以查询的唯一属性是电子邮件和用户名.但是,如果它不起作用,他们为什么会提供此功能.我错过了什么?
我想向组提交用户创建请求,但不确定如何在express-stormpath中执行此操作.
现在我使用注册前和注册后处理程序来获取一个字段,从formData中删除它,传递给res,然后在post registration handler上设置组:
preRegistrationHandler: function (formData, req, res, next) {
res.locals.describes = formData.describes;
delete formData.describes;
next();
},
postRegistrationHandler: function (account, req, res, next) {
var seekerHref = config.SEEKERS_HREF;
var employerHref = config.EMPLOYERS_HREF;
if (res.locals.describes === "seeker") {
//Adding to seeker group
account.addToGroup(seekerHref, function(err, membership) {
console.log(membership);
});
} else if (res.locals.describes === "employers") {
//Adding to the employer group
account.addToGroup(employerHref, function(err, membership) {
console.log(membership);
});
}
delete res.locals.describes;
next();
}
Run Code Online (Sandbox Code Playgroud)
这似乎不是一个好主意.如果连接不可用且组分配失败会发生什么?用户可能在没有组的情况下陷入困境.
以下代码从angularjs开始,然后通过节点进行路由,然后该节点应进行外部api调用.发生了什么,stormpath正在拦截呼叫并尝试对其进行身份验证(登录屏幕已提供...我检查了res.data).我认为应用程序很好,因为我最初必须登录.我没有在ui-router中定义路由,因为我希望节点处理它而不是角度.所以,我的问题是如何配置不同的层来处理呼叫.
angular - > node/stormpath - > external api
节点路由:
app.use('/api/v1/accounts/:search', stormpath.groupsRequired(['dataentry']), apiAccounts.findAll);
Run Code Online (Sandbox Code Playgroud)
stormpath设置:
app.use(stormpath.init(app, {
apiKeyFile: config.stormpathapi.apiKeyFile,
application: config.stormpathapi.application,
secretKey: config.stormpathapi.secretKey,
sessionDuration: 1000 * 60 * 30,
enableAutoLogin: true,
enableUsername: true
}));
Run Code Online (Sandbox Code Playgroud)
角度代码:
$scope.getCustomers = function(chars) {
var customers = [],
url = 'api/v1/accounts/' + encodeURIComponent(chars) + '/';
console.log('getCustomers: ' + url);
try
{
//return $http.jsonp(url)
return $http.get(url)
.then(function(res) {
if(angular.isArray(res.data))
{
customers = res.data;
}
return customers;
}, function (error) {
console.log('Unable to load the customers: ' + …Run Code Online (Sandbox Code Playgroud) 我有一个Scala使用spray.io构建的简单应用程序.我正在使用Scala 2.11.2和SBT 0.13.0.我的所有依赖项都列在这里:
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.6",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.6",
"io.spray" % "spray-can_2.11" % "1.3.2",
"io.spray" % "spray-routing_2.11" % "1.3.2",
"io.spray" % "spray-json_2.11" % "1.3.1"
)
libraryDependencies += "org.mongodb" %% "casbah" % "2.7.2"
libraryDependencies += "com.stormpath.sdk" % "stormpath-sdk-api" % "1.0.RC4.2"
libraryDependencies += "com.stormpath.sdk" % "stormpath-sdk-httpclient" % "1.0.RC4.2"
Run Code Online (Sandbox Code Playgroud)
虽然在本地构建和运行它一切都很好但是当我尝试将其推送/部署到PaaS像cloudControl或heroku这样的平台时,我遇到了依赖性问题:
[info] Resolving org.apache.httpcomponents#httpclient;${httpclient.version} ...
[warn] module not found: org.apache.httpcomponents#httpclient;${httpclient.version}
[warn] ==== local: …Run Code Online (Sandbox Code Playgroud) 我正在尝试确定登录用户是否是特定Stormpath组的成员.
以下工作,但它基于错误的属性(groups.href)
<div th:text="${#lists.contains(account.groups.href, 'https://api.stormpath.com/v1/accounts/eXaMpLe12345/groups')}" />
Run Code Online (Sandbox Code Playgroud)
而我试图找到(伪代码) groups.isMemberOf('https://api.stormpath.com/v1/accounts/mYgRrOuP1234/groups')
我知道如何遍历组并打印出所有数据,我可以看到我想要找到的组的href,但我不知道如何通过它的href访问它.
<div th:if="${account.groups != null}">
<ul>
<li th:each="group : ${account.groups}" th:text="${group.href}">group details...</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)