MrsSunny / SSO-OpenSAML

SSO with OpenSAML2.X or Application with spring mvc、spring security
27 stars 20 forks source link

项目问题 #1

Open xgtxxxx opened 7 years ago

xgtxxxx commented 7 years ago

你好,我看了你的saml这块代码,但是IDP和SP应该是分别部署吧,怎么项目的工作流程没怎么看明白。 我个认为如果只谈单点登录的话,IDP应该有两个方法:

  1. 接受AuthnRequest,判定是否已经登录,如果登录则直接反馈success的response, 如果用户没有登录,则跳转login
  2. 处理用户login,成功后反馈response给sp

SP应该也应该只需要配置spring security,简单如下: ` ......

<intercept-url pattern="/saml/assertionConsumer" access="hasRole('SOME_ROLE')"/>
<intercept-url pattern="/**" access="hasRole('SOME_ROLE')"/>
......

`

samlAuthenticationEntryPoint: 在这里面封装AuthnRequest, 并请求IDP。 /saml/assertionConsumer: 这个是IDP响应成功后的地址, 通过samlSolicitedFilter拦截后将认证信息更新到SP的session里面去,然后跳转到最初访问SP的地址。

我做个一个小实验,我的request如下: <?xml version="1.0" encoding="UTF-8"?> <saml2p:AuthnRequest AssertionConsumerServiceURL="http://localhost:9091/saml/assertionConsumer" Destination="http://localhost:8080/idp/sso/login" ID="679ed10b-4d47-45d8-baca-b187b34c7496" IssueInstant="2016-09-23T09:20:04.832Z" Version="2.0" xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"> <saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">http://sp-demo</saml2:Issuer> </saml2p:AuthnRequest>

response: `<?xml version="1.0" encoding="UTF-8"?> <saml2p:Response Destination="http://localhost:9091/saml/assertionConsumer" ID="a7d6fc8d-d465-4fa0-8dfe-25dbcc0361c1" InResponseTo="679ed10b-4d47-45d8-baca-b187b34c7496" IssueInstant="2016-09-23T09:20:05.023Z" Version="2.0" xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"> <saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">http://idp-demo</saml2:Issuer>

http://idp-demo xo8TAQkMXhQniFDhhrQspRQ8kl0= i3u6+VcRaBtfqRtKafrxaq2OgDgpfNFgtnf8Q8wsd0EvTgS/53sRLC0kiCarZHvnvN/eX+qHuhv9any+Nyd5gdFw+A/4mOFlF8AvcFQMcYuJjOfY0b2hGzWOnY4Rx1i2x6I+6ON2wiptP1SaQ7KTxph2DPMiIbBZVuP2QCZXmzU= admin urn:oasis:names:tc:SAML:2.0:ac:classes:Password ...... ` 虽然成功了,但是对opensaml还是云里雾里的,有机会可以一起探讨下。
Lyfun commented 7 years ago

你好,你能告诉我怎么配置这个saml工程让它能跑起来 @xgtxxxx

xgtxxxx commented 7 years ago

我这有个简单例子 https://github.com/xgtxxxx/sso-demo