我正在尝试使用 spring security(spring-security-starter) 在 spring boot(2.2.4) 应用程序中实现身份验证和授权。
用例:根据用户名,我想将用户重定向到特定的身份验证提供商
如果用户名以“einfochips.com”结尾,则使用 SAML 2.0 协议对用户进行身份验证 - 使用 Okta、SSOCircle、OneLogin 等身份提供商。
我不知道我该怎么做。我尝试使用自定义过滤器但无法做到。
我已经阅读了很多文章但无法实现这一目标。
我编写了以下仅使用 SAML 进行身份验证的代码。它运行良好。将用户带到 okta idp 进行登录。
package com.example.demo;
import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.saml.userdetails.SAMLUserDetailsService;
@EnableWebSecurity
@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
SAMLUserDetailsService userDetailsService;
@Value("${security.saml2.metadata-url}")
String metadataUrl;
@Value("${server.ssl.key-alias}")
String keyAlias;
@Value("${server.ssl.key-store-password}")
String password;
@Value("${server.port}")
String port;
@Value("${server.ssl.key-store}")
String …Run Code Online (Sandbox Code Playgroud) spring-security saml saml-2.0 spring-boot spring-security-saml2
看起来Spring总是用来InMemoryRelyingPartyRegistrationRepository返回RelyingPartyRegistrationRepository类型化的bean,请参阅https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/ java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java。
问题:我如何注入(自动装配)我自己的实现RelyingPartyRegistrationRepository?假设我希望在更新某个客户的 SAML 配置后,允许自动连接依赖方存储库从数据库自动重新加载。这可行吗?
我正在研究SSO技术,特别是SAML 2.0,我看到IdP,IdP Lite,SP和SP Lite的运行模式.我能找到的这些"精简"模式的唯一参考是SAML 2.0规范的一致性部分.
完整版和轻型版之间的唯一区别是"lite"版本是完整版本的子集吗?如果他们使用Lite版本,那么人们会失去哪些关键功能?
我可以使用OpenSAML创建一个断言,但我想签名.签名可以通过两种方式完成:1.自签
2.使用第三方(verisign等)
使用OpenSAML自我签名断言的步骤是什么?
我正在尝试将SAML与ColdFusion 9 Enterprise集成.我面临的问题与我正在做的SAML请求有关.我正在使用CFLOCATION来提出请求.当我发出请求时,对服务器的请求被作为GET请求,我SAML服务器期望它是一个POST请求,最终不会匹配从我的服务器发送到SAML服务器的令牌.
我不确定是什么原因造成的.我也尝试使用CFHTTP发出请求使redirect ="yes"在这种情况下它不会重定向到url并且不会在firebug或SAML tracer中给出任何错误.
谁能帮帮我吗?急切地等待回应.
谢谢 :)
我有一个SimpleSamlPHP实现作为服务提供者,因此工作流程如下:
IdP向我的ACS URL发送断言:
/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp
但后来看起来他认证并被重定向到
/simplesaml/module.php/saml/sp/saml2-acs.php
由于没有指定authsource(/ default-sp部分),因此抛出错误:
SimpleSAML_Error_Error: UNHANDLEDEXCEPTION
Backtrace:
0 *\simplesamlphp\www\module.php:180 (N/A)
Caused by: SimpleSAML_Error_Exception: No authentication source with id false found.
Backtrace:
2 *\simplesamlphp\lib\SimpleSAML\Auth\Source.php:242 (SimpleSAML_Auth_Source::getById)
1 *\simplesamlphp\modules\saml\www\sp\saml2-acs.php:8 (require)
0 *\simplesamlphp\www\module.php:135 (N/A)
Run Code Online (Sandbox Code Playgroud)
但是,它也有一组PHP错误输出到页面:
Warning: array_key_exists(): The first argument should be either a string or an integer in *\simplesamlphp\lib\SimpleSAML\Configuration.php on line 314
Warning: Cannot modify header information - headers already sent by (output started at *\simplesamlphp\lib\SimpleSAML\Configuration.php:314) in *\simplesamlphp\lib\SimpleSAML\Error\Error.php on line 191
Warning: Cannot modify header information - headers already …Run Code Online (Sandbox Code Playgroud) 我开发了一个Java Web应用程序,我想实现SAML.这些是我认为实施SAML的正确步骤.
我有一个示例代码,我能够创建SAML请求,就像这样
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
ID="_c7b796f4-bc16-4fcc-8c1d-36befffc39c2" Version="2.0"
IssueInstant="2014-10-30T11:21:08Z" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
AssertionConsumerServiceURL="http://localhost:8080/mywebapp/consume.jsp">
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">http://localhost:8080/mywebapp
</saml:Issuer>
<samlp:NameIDPolicy
Format="urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified"
AllowCreate="true"></samlp:NameIDPolicy>
<samlp:RequestedAuthnContext Comparison="exact">
<saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
</saml:AuthnContextClassRef>
</samlp:RequestedAuthnContext>
</samlp:AuthnRequest>
Run Code Online (Sandbox Code Playgroud)
我可以编码并发送给IdP.
我想创建示例Java代码以获取此SAML请求,然后创建SAML响应.如何解码请求并验证并创建响应?我是否需要使用证书签署saml响应?然后发送回SP?
谢谢.
SAML回复
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_8e8dc5f69a98cc4c1ff3427e5ce34606fd672f91e6" Version="2.0" IssueInstant="2014-07-17T01:01:48Z" Destination="http://sp.example.com/demo1/index.php?acs" InResponseTo="ONELOGIN_4fee3b046395c4e751011e97f8900b5273d56685">
<saml:Issuer>http://idp.example.com/metadata.php</saml:Issuer>
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</samlp:Status>
<saml:Assertion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" ID="_d71a3a8e9fcc45c9e9d248ef7049393fc8f04e5f75" Version="2.0" IssueInstant="2014-07-17T01:01:48Z">
<saml:Issuer>http://idp.example.com/metadata.php</saml:Issuer>
<saml:Subject>
<saml:NameID SPNameQualifier="http://sp.example.com/demo1/metadata.php" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">_ce3d2948b4cf20146dee0a0b3dd6f69b6cf86f62d7</saml:NameID>
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData NotOnOrAfter="2024-01-18T06:21:48Z" Recipient="http://sp.example.com/demo1/index.php?acs" InResponseTo="ONELOGIN_4fee3b046395c4e751011e97f8900b5273d56685"/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="2014-07-17T01:01:18Z" NotOnOrAfter="2024-01-18T06:21:48Z">
<saml:AudienceRestriction>
<saml:Audience>http://sp.example.com/demo1/metadata.php</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant="2014-07-17T01:01:48Z" SessionNotOnOrAfter="2024-07-17T09:01:48Z" SessionIndex="_be9967abd904ddcae3c0eb4189adbe3f71e327cf93">
<saml:AuthnContext>
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
<saml:AttributeStatement>
<saml:Attribute Name="uid" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
<saml:AttributeValue xsi:type="xs:string">test</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute Name="mail" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
<saml:AttributeValue xsi:type="xs:string">test@example.com</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute Name="eduPersonAffiliation" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
<saml:AttributeValue xsi:type="xs:string">users</saml:AttributeValue>
<saml:AttributeValue xsi:type="xs:string">examplerole1</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
</samlp:Response>
Run Code Online (Sandbox Code Playgroud)
需要从上面的xml中检索属性
array (
'uid' =>
array (
0 …Run Code Online (Sandbox Code Playgroud) 我知道很多服务提供商使用中继状态来跟踪SP启动SSO时访问的资源,因此SP可以在SAML断言消耗后重定向到它.
但是,我正在查看SAML响应的Destination属性,它看起来像是专为此案例设计的.
我错过了什么吗?为什么服务提供商以这种方式使用中继状态(与使用目的地相比)?
我正在使用Identity和Sustainsys.Saml2(用于SAML身份验证)开发ASP.NET Core 2应用程序。我已经在Startup.cs文件中进行了必要的配置。现在,当我运行项目并尝试使用SAML2登录(作为外部登录名)时,输入凭据后出现以下错误:
SecurityTokenInvalidAudienceException:IDX10214:听众验证失败。观众:“ [PII隐藏]”。不匹配:validationParameters.ValidAudience:“ [PII隐藏]”或validationParameters.ValidAudiences:“ [PII隐藏]”。Microsoft.IdentityModel。令牌令牌,TokenValidationParameters验证参数,不包括SecurityToken validatedToken)Sustainsys.Saml2.Saml2P.Saml2Response + d__60.MoveNext()System.Collections.Generic。
我不明白这是什么意思。我想念什么吗?
这是我在启动文件中的内容
services.AddAuthentication()
.AddSaml2(options =>
{
var spOptions = new SPOptions
{
EntityId = new EntityId("https://localhost:44373/Saml2"),
ReturnUrl = new Uri("https://localhost:44373"),
MinIncomingSigningAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
};
options.SPOptions = spOptions;
options.IdentityProviders.Add(new IdentityProvider(new EntityId("https://www.example.com/SSO/SAML/App"), options.SPOptions)
{
AllowUnsolicitedAuthnResponse = false,
MetadataLocation = "https://www.example.com/SSO/SAMLMetadata/App",
LoadMetadata = true,
});
});
Run Code Online (Sandbox Code Playgroud)
提前致谢...
saml ×10
saml-2.0 ×7
java ×3
php ×2
asp.net-core ×1
assertions ×1
c# ×1
coldfusion ×1
coldfusion-9 ×1
opensaml ×1
spring-boot ×1
xml ×1