我正在使用Spring Security构建一个Web应用程序,该应用程序将存在于Amazon EC2上并使用Amazon的Elastic Load Balancers.不幸的是,ELB不支持粘性会话,因此我需要确保我的应用程序在没有会话的情况下正常工作.
到目前为止,我已经设置了RememberMeServices来通过cookie分配令牌,这很好用,但我希望cookie随浏览器会话一起过期(例如当浏览器关闭时).
我不得不想象我不是第一个想要在没有会话的情况下使用Spring Security的人......有什么建议吗?
我已按照此处列出的步骤创建新的私钥和证书。现在我试图将它们组合成一个 .pfx 文件。
OpenSSL 应该能够从单个文件中读取私钥和证书,并且根据 manman
文档,也应该能够从stdin
. 但是,这似乎对我不起作用。
在 Mac OS X 10.14.3 上并openssl version
给出“LibreSSL 2.6.5”。
我将我的证书和密钥合并到一个文件中(称为“combined.pem”)。我使用以下命令执行此操作:
$ openssl genrsa -out private.key 2048
$ openssl req -new -x509 -key private.key -out public.cer -days 365
$ cat public.cer >> combined.pem
$ cat private.key >> combined.pem
Run Code Online (Sandbox Code Playgroud)
作为参考,combined.pem
看起来像这样:
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)
当我运行以下命令时,一切正常:
$ openssl pkcs12 -export -out x509.pfx -in combined.pem
Run Code Online (Sandbox Code Playgroud)
当我运行此命令时,出现错误: …
我正在使用Spring Security的RememberMe服务来保持用户的身份验证.
我想找到一种简单的方法将RememberMe cookie设置为会话cookie而不是固定的到期时间.对于我的应用程序,cookie应该持续到用户关闭浏览器.
有关如何最好地实现这一点的任何建议?对此的任何担忧都是潜在的安全问题?
这样做的主要原因是,使用基于cookie的令牌,我们的负载均衡器后面的任何服务器都可以为受保护的请求提供服务,而无需依赖用户的身份验证来存储在HttpSession中.事实上,我明确告诉Spring Security永远不会使用命名空间创建会话.此外,我们使用的是亚马逊的Elastic Load Balancing,因此不支持粘性会话.
注意:虽然我知道截至4月8日,亚马逊现在支持粘性会话,但我仍然不想出于其他一些原因使用它们.也就是说,一台服务器的不合时宜的消亡仍会导致与之相关的所有用户丢失会话. http://aws.amazon.com/about-aws/whats-new/2010/04/08/support-for-session-stickiness-in-elastic-load-balancing/
当我的Gemfile中发布的新版Gems被发布时,是否有人知道监视和提醒我的任何工具?
它可以像报告当前版本和最新版本的rake任务一样简单,也可以像后台进程一样简单,只要有新版本可以将消息记录到控制台.
我正在Rails中建模一个复杂的采购工作流程,该流程将请购单转换为订单。我正在使用FactoryGirl进行测试,一切都很好,直到尝试测试OrderLineItem,该OrderLineItem依赖于Order和Quote,后者分别依赖于其他对象,依此类推...
有问题的测试检查受产品影响的OrderLineItem的行为,该行为是产品链上的多个关联。
有没有设置FactoryGirl的好方法,这样我就可以轻松构建OrderLineItems并指定链中较高对象的行为,而不必一次考虑每个对象?
这是我的对象图:
class Requisition
has_many :requisition_line_items
has_many :orders
end
class RequisitionLineItem
belongs_to :requisition
belongs_to :product
has_many :quotes
end
class Quote
belongs_to :line_item
belongs_to :vendor
has_one :order_line_item
end
class Order
belongs_to :requisition
belongs_to :vendor
has_many :order_line_items
end
class OrderLineItem
belongs_to :order
belongs_to :quote
has_many :assets
end
class Asset
belongs_to :order_line_item
belongs_to :product
end
class Product
has_many :assets
end
class Vendor
has_many :orders
end
Run Code Online (Sandbox Code Playgroud)
看似复杂的模型允许根据供应商的报价将购买的“建议”转换为一个或多个实际订单,并且当物品到达时,会为其赋予资产标签。然后可以将资产本身链接回订单和供应商,以在以后提供支持。
这是我的OrderLineItem规范,我有一个比较简洁的设置:
describe '#requires_tag?' do
let(:product) { FactoryGirl.create :product, requires_tag: false }
let(:purchase_requisition) { FactoryGirl.create :purchase_requisition …
Run Code Online (Sandbox Code Playgroud) DefaultLdapAuthoritiesPopulator 设置搜索范围为“ONE_LEVEL”,但我需要搜索“SUBSCOPE”以获取用户所属组的列表。
我一直遵循“配置”风格的 Spring 设置(代码,而不是 XML)。虽然有大量关于如何在 XML 中配置自定义 LdapAuthoritiesPopulator 的示例,但我对如何在代码中执行此操作感到困惑。
这是我到目前为止所拥有的:
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.contextSource().url("ldap://ldap.company.org/")
.and()
.userSearchBase("o=company.org,c=us")
.userSearchFilter("(uid={0})")
.groupSearchBase("o=company.org,c=us")
.groupSearchFilter("(&(objectClass=groupOfUniqueNames)(uniqueMember={0}))");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin().and().authorizeRequests()
.antMatchers("/api/**").authenticated()
.anyRequest().permitAll();
}
}
Run Code Online (Sandbox Code Playgroud)
缺少的是我需要能够在 DefaultLdapAuthoritiesPopulator 上设置搜索范围。该类本身公开了“setSearchSubtree”方法,但 LdapAuthenticationProviderConfigurer 不提供配置它的方法。
有什么建议么?
当我dotnet publish
使用 Mac 在控制台应用程序上运行时,结果.dll
在bin/Debug/<framework>/publish
目录中。
当我使用 Microsoft .NET SDK Docker 容器在相同的源代码上运行相同的命令时,结果是一个可执行的二进制文件,除了.dll
.
为什么会有差异?为什么不在dotnet publish
macOS 上生成可执行的二进制文件?
我已经使用 .NET Core 3.1 和 .NET 5.0 进行了尝试,并得到了相同的结果。这是我的 .NET 5.0 进程:
首先,我跑dotnet new console
从头开始生成一个新项目。我在生成的输出中没有改变任何东西。生成的.csproj
看起来像这样:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>MyApp</RootNamespace>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
dotnet publish
从 macOS运行会产生以下结果:
$ dotnet publish
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored /src/my-app.csproj (in 68 ms). …
Run Code Online (Sandbox Code Playgroud) spring ×3
.net ×1
.net-core ×1
amazon-ec2 ×1
bdd ×1
c# ×1
factory-bot ×1
ldap ×1
openssl ×1
remember-me ×1
rspec ×1
ruby ×1
rubygems ×1
security ×1
x509 ×1