元ネタ: https://github.com/korteke/Shibboleth-IdP3-TOTP-Auth
上記ページのreleasesタブから totpauth-impl-NNN-bin.zip をダウンロード、展開。
conf/, edit-webapp/, flows/, views/ の内容をディレクトリ構造を保持したまま/opt/shibboleth-idp/以下に配置。
idp.propertiesのidp.authn.flowsに"|Totp"を追加。
-idp.authn.flows = Password +idp.authn.flows = Password|Totp
conf/authn/general-authn.xmlの <util:list id="shibboleth.AvailableAuthenticationFlows">
の子要素として以下を挿入します。TOTPの優先順位を高くしたければ先頭に挿入してください。
<bean id="authn/Totp" parent="shibboleth.AuthenticationFlow" p:passiveAuthenticationSupported="true" p:forcedAuthenticationSupported="true"> <property name="supportedPrincipals"> <util:list> <bean parent="shibboleth.SAML2AuthnContextClassRef" c:classRef="urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken" /> </util:list> </property> </bean>
conf/authn/totp-authn-beans.xmlにLDAPの情報を記述します。ldap.propertiesに記述している場合は以下のように修正してください。LDAPのbindDNの権限で読み込みに加えて書き込みもできることを確認しておいてください。
@@ -37,10 +37,10 @@ </bean> <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"> - <property name="url" value="LDAP_SERVER_URL" /> - <property name="base" value="BASE_DN" /> - <property name="userDn" value="MANAGERS DN" /> - <property name="password" value="PASSWORD" /> + <property name="url" value="%{idp.attribute.resolver.LDAP.ldapURL}" /> + <property name="base" value="%{idp.attribute.resolver.LDAP.baseDN}" /> + <property name="userDn" value="%{idp.attribute.resolver.LDAP.bindDN}" /> + <property name="password" value="%{idp.attribute.resolver.LDAP.bindDNCredential}" /> </bean> <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
以下は3.3向け修正。
flows/authn/Totp/Totp-flow.xmlに登録のための遷移が宣言されていないので追加します。
@@ -26,6 +26,7 @@ result="viewScope.custom" /> </on-render> + <transition on="RegisterToken" to="RegisterToken" /> <transition on="proceed" to="ExtractTotpFromForm" /> </view-state>
conf/authn/password-authn-config.xmlにパスワードを持ち回る必要があるため以下の行を追加します。
@@ -23,6 +23,8 @@ <bean id="shibboleth.authn.Password.PasswordFieldName" class="java.lang.String" c:_0="j_password" /> <bean id="shibboleth.authn.Password.SSOBypassFieldName" class="java.lang.String" c:_0="donotcache" /> + <util:constant id="shibboleth.authn.Password.RemoveAfterValidation" static-field="java.lang.Boolean.FALSE"/> + <!-- Simple transforms to apply to username before validation. --> <util:constant id="shibboleth.authn.Password.Lowercase" static-field="java.lang.Boolean.FALSE"/> <util:constant id="shibboleth.authn.Password.Uppercase" static-field="java.lang.Boolean.FALSE"/>
最後に、Tomcatを起動したまま/opt/shibboleth-idp/bin/build.shを実行し、WARファイル再作成およびデプロイします。