【发布时间】:2014-11-27 09:01:30
【问题描述】:
我们已经将 shibboleth web sso 集成到我们的应用程序中来验证用户,现在我们想要 为我们的申请做授权。以下是我正在考虑进行身份验证的过程。
- 根据 shibboleth idp,未经身份验证的用户从 idp 重定向到 login.jsp
- 一旦用户输入用户名和密码,页面就会进入我们的数据库 并验证用户是否有效。 在这里,如果用户通过身份验证,我想获取用户的权限。
- 现在用户再次使用一些信息以及权限重定向到 idp, 所以 idp 使用该权限重定向到我们的服务提供商,不,我们可以控制授权 为用户。 在这里我知道我必须处理 attribute-resolver.xml,现在我们正在使用 这个xml中的原理和transientId。所以我知道我可以从 saml 响应中获取所需的信息(权限) 来自 shibboleth idp。
那么请告诉我,如何处理attribute-resolver.xml来添加我们的授权权限。 Imp 问题:使用 shibboleth 进行授权的更好流程是什么?
请查看我正在关注的以下流程... 使用 idp 的身份验证流程,我们正在编写自己的 SP。 1) 以下 encodeSaml 请求将发送到 Idp,如下所示:
public Pair<String,String> getSAMLRequest(String spUrl, String consumerUrl) {
AuthnRequest authnRequest = null;
//String encodedSAMLRequest = null;
Pair<String,String> encodedSAMLRequest = null;
try {
authnRequest = this.buildAuthnRequestObject(spUrl, consumerUrl);
Encoder encoder = Encoder.getEncoder();
encodedSAMLRequest = encoder.encodeAuthnRequest(authnRequest);
} catch (MarshallingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return encodedSAMLRequest;
}
private AuthnRequest buildAuthnRequestObject(String spUrl,
String consumerUrl) {
Issuer issuer = getIssuer();
issuer.setValue(spUrl);
DateTime issueInstant = new org.joda.time.DateTime();
RequestedAuthnContext requestedAuthnContext = getRequestedAuthnContext();
AuthnRequest authRequest = getAuthnRequest(issueInstant, issuer,
consumerUrl, spUrl);
authRequest.setRequestedAuthnContext(requestedAuthnContext);
String systemTime = System.currentTimeMillis() + "";
authRequest.setID("SSOIDSAMLREQ" +systemTime);
authRequest.setVersion(SAMLVersion.VERSION_20);
authRequest.setAssertionConsumerServiceIndex(1);
return authRequest;
}
2) First time idp redirects the user to login.jsp by using configuration which is in the handler.xml using externalAuth
<ph:LoginHandler xsi:type="ph:ExternalAuthn"
externalAuthnPath="/external/login"
supportsForcedAuthentication="true" >
<ph:AuthenticationMethod>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</ph:AuthenticationMethod>
</ph:LoginHandler>
-->一旦进入上述路径,用户就可以看到 login.jsp 并且用户将输入凭据并提交到我们的服务器以验证用户。所以我们会得到这个用户是否有效的布尔变量。
-> 一旦我们从服务器获得状态,我们正在准备请求和响应,如下所示,将再次将其发送到 idp(AuthenticationEngine.returnToAuthenticationEngine(req,resp))。
request.setAttribute(globalStrings.getForceAuthn(), false);
Principal principal = new UsernamePrincipal(login.getAttributes());
Subject subj = new Subject();
subj.getPrincipals().add(principal);
request.setAttribute(LoginHandler.PRINCIPAL_KEY, principal);
request.setAttribute(LoginHandler.PRINCIPAL_NAME_KEY, personId);
request.setAttribute(LoginHandler.SUBJECT_KEY, subj);
request.setAttribute(globalStrings.getAuthnMethod(), this.authenticationMethod);
AuthenticationEngine.returnToAuthenticationEngine(request, response);
3) We mention in the attribute-resolver and attribute-filter for the attributes to be released to the SP like below
<resolver:AttributeDefinition id="principal" xsi:type="PrincipalName" xmlns="urn:mace:shibboleth:2.0:resolver:ad">
<resolver:AttributeEncoder xsi:type="enc:SAML2StringNameID" />
<resolver:AttributeEncoder xsi:type="SAML2Base64" xmlns="urn:mace:shibboleth:2.0:attribute:encoder"
name="ORG_ATTRIBUTE_64" />
<resolver:AttributeEncoder xsi:type="SAML2String" xmlns="urn:mace:shibboleth:2.0:attribute:encoder"
name="ORG_ATTRIBUTE" />
</resolver:AttributeDefinition>
4) 所以会从SP(SAML响应)中获取发布的所需属性,并做进一步的处理(授权)。
【问题讨论】:
-
如何获取此查询的视图或者我是否需要提供其他信息?请回复任何人?
标签: java web-applications authorization shibboleth