First thing that popped out in my mind after basic installation/configuration worked was to check how could be the login page customized. But where to find that page?
The answer is simple: login.vm (idp-conf\src\main\resources\views\login.vm
), a template based on Velocity. It was easy to find: look at the id assigned to password field (for instance), j_password
and do a recursive search in sources directory.
Note: If changing main.css is necessary please notice that the UI part is packed as idp.war...
This is not enough; we want to understand how it works and where to look if we get into trouble.
To start with: a lot of Shibbolet functionality (including UI behaviour) is based on Spring Web Flow. The main configuration file (webflow-config.xml
) can be found by looking into web.config
.
<servlet>
<servlet-name>idp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>${idp.home}/system/conf/mvc-beans.xml, ${idp.home}/system/conf/webflow-config.xml</param-value>
</init-param>
...
It defines application web-flows accessible through the registry (org.springframework.webflow.definition.registry.FlowDefinitionRegistryImpl
, method getFlowDefinition
, spring-webflow-2.4.1.RELEASE.jar
).
The flow we are interested in is that with id="SAML2/Unsolicited/SSO"
. When we access HTTPS://<shibblolet-url>:<https-port>/idp/profile/SAML2/Unsolicited/SSO?providerId=<SP_entityID>
DispatcherHandler
will finally call org.springframework.webflow.mvc.servlet.FlowHandlerMapping
, method getHandlerInternal
, parameter HttpServletRequest request
. Request properties are as follows:
- contextPath: "/idp"
- servletPath: "/profile"
- pathInfo: "/SAML2/Unsolicited/SSO"
Based on pathInfo
the web-flow with the matching id is activated. A breakpoint set in org.springframework.webflow.executor.FlowExecutorImpl
, method launchExecution
, after FlowDefinition flowDefinition = definitionLocator.getFlowDefinition(flowId);
allows us to examine flowDefinition
and see the states defined in the work-flow that is about to be executed.
Having a look in the flow definition (path="../system/flows/saml/saml2/sso-unsolicited-flow.xml"
) is quite confusing for the newbies: no actually flow description (according to what you will see in tutorials) but just two regular Spring beans definition: the point is that any such bean exposing an 'execute' method will be treated as a state-action and the methods will be called in the order of bean definition.
OK, but where comes in action our login.vm
? The parent="saml2.sso.abstract"
attribute in flow tag definition is the key: our flow inherits its definition from that flow (identified by this id in web-config.xml
). Somehow (I haven't checked all the inheritance/definitions chain) the authn/Password
sub-flow is activated, sub-flow that contains a view-state
referring our template in the view attribute:
<view-state id="DisplayUsernamePasswordPage" view="login">
<on-render>
<evaluate expression="environment" result="viewScope.environment" />
<evaluate expression="opensamlProfileRequestContext" result="viewScope.profileRequestContext" />
<evaluate expression="opensamlProfileRequestContext.getSubcontext(T(net.shibboleth.idp.authn.context.AuthenticationContext))" result="viewScope.authenticationContext" />
...
The transition <transition on="proceed" to="ExtractUsernamePasswordFromFormRequest">
is activated when the Login button is pressed (id='_eventId_proceed'
-> proceed
constant will become available to be evaluated by the transition condition based on the convention id=_eventId_...
).
Action state ExtractUsernamePasswordFromFormRequest
will be executed:
<action-state id="ExtractUsernamePasswordFromFormRequest">
<evaluate expression="ExtractUsernamePasswordFromFormRequest" />
<evaluate expression="'proceed'" />
<!-- Let the validate action handle any problems later. -->
<transition to="ValidateUsernamePassword" />
</action-state>
The <evaluate expression="ExtractUsernamePasswordFromFormRequest" />
has the role to call execute
method of bean with id="ExtractUsernamePasswordFromFormRequest"
( class defined in module Shibboleth IdP :: Authentication Implementation
) while <evaluate expression="'proceed'"/>
just makes 'proceed'
the current value to be evaluated by subsequent transitions (not actually used here but pattern used in may other places).
Finally we land in ValidateUsernamePasswordAgainstLDAP.execute
method.
DQpGaXJzdCB0aGluZyB0aGF0IHBvcHBlZCBvdXQgaW4gbXkgbWluZCBhZnRlciBiYXNpYyBpbnN0YWxsYXRpb24vY29uZmlndXJhdGlvbiB3b3JrZWQgd2FzIHRvIGNoZWNrIGhvdyBjb3VsZCBiZSB0aGUgbG9naW4gcGFnZSBjdXN0b21pemVkLiAgQnV0IHdoZXJlIHRvIGZpbmQgdGhhdCBwYWdlPw0KDQpUaGUgYW5zd2VyIGlzIHNpbXBsZTogbG9naW4udm0gKGBpZHAtY29uZlxzcmNcbWFpblxyZXNvdXJjZXNcdmlld3NcbG9naW4udm1gKSwgYSB0ZW1wbGF0ZSBiYXNlZCB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RhdGVVc2VybmFtZVBhc3N3b3JkIiAvPg0KICAgIDwvYWN0aW9uLXN0YXRlPg0KYGBgDQpUaGUgYDxldmFsdWF0ZSBleHByZXNzaW9uPSJFeHRyYWN0VXNlcm5hbWVQYXNzd29yZEZyb21Gb3JtUmVxdWVzdCIgLz5gIGhhcyB0aGUgcm9sZSB0byBjYWxsIGBleGVjdXRlYCBtZXRob2Qgb2YgYmVhbiB3aXRoIGBpZD0iRXh0cmFjdFVzZXJuYW1lUGFzc3dvcmRGcm9tRm9ybVJlcXVlc3QiYCAoIGNsYXNzIGRlZmluZWQgaW4gbW9kdWxlIGBTaGliYm9sZXRoIElkUCA6OiBBdXRoZW50aWNhdGlvbiBJbXBsZW1lbnRhdGlvbmApIHdoaWxlIGA8ZXZhbHVhdGUgZXhwcmVzc2lvbj0iJ3Byb2NlZWQnIi8+YCBqdXN0IG1ha2VzIGAncHJvY2VlZCdgIHRoZSBjdXJyZW50IHZhbHVlIHRvIGJlIGV2YWx1YXRlZCBieSBzdWJzZXF1ZW50IHRyYW5zaXRpb25zIChub3QgYWN0dWFsbHkgdXNlZCBoZXJlIGJ1dCBwYXR0ZXJuIHVzZWQgaW4gbWF5IG90aGVyIHBsYWNlcykuDQoNCkZpbmFsbHkgd2UgbGFuZCBpbiBgVmFsaWRhdGVVc2VybmFtZVBhc3N3b3JkQWdhaW5zdExEQVAuZXhlY3V0ZWAgbWV0aG9kLg==
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletetry <base URL>/idp/profile/SAML2/Unsolicited/SSO?providerId= < your ID as specified in metadata file for the Service Provider (should be in metadata subdirectory of your shibboleth installation)>
ReplyDelete