[JIRA] (IDP-1881) Failed TemplateAttribute should generate a runtime warning (or error)

Rod Widdowson (Jira) jira at shibboleth.atlassian.net
Tue Dec 7 15:05:27 UTC 2021


Rod Widdowson ( https://shibboleth.atlassian.net/secure/ViewProfile.jspa?accountId=59fb32bbc24efb3c4ed3c977 ) *commented* on IDP-1881 ( https://shibboleth.atlassian.net/browse/IDP-1881?atlOrigin=eyJpIjoiMTVhNGU4MDAyMWE2NGM0Zjg0Mjc1YTgwZmFlMjZmODciLCJwIjoiaiJ9 )

Re: Failed TemplateAttribute should generate a runtime warning (or error) ( https://shibboleth.atlassian.net/browse/IDP-1881?atlOrigin=eyJpIjoiMTVhNGU4MDAyMWE2NGM0Zjg0Mjc1YTgwZmFlMjZmODciLCJwIjoiaiJ9 )

“Field Fix” for V4.1.*
----------------------

Add the following to global.xml

   <util:map id="shibboleth.VelocityEngineProperties">
       <entry key="parser.space_gobbling" value="%{idp.velocity.space.gobbling:bc}" />
       <entry key="resource.loaders" value="file, classpath, string" />
       <entry key="resource.loader.classpath.class" value="org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" />
       <entry key="resource.loader.string.class" value="org.apache.velocity.runtime.resource.loader.StringResourceLoader" />
       <entry key="resource.loader.file.class" value="org.apache.velocity.runtime.resource.loader.FileResourceLoader" />
       <entry key="resource.loader.file.path" value="#{'%{idp.views:%{idp.home}/views}'.trim()}" />
       <entry key="resource.loader.file.cache" value="false" />
       <entry key="runtime.strict_mode.enable" value="true" />
   </util:map>

Then no attributes will resolve and your log will get this:

2021-12-07 14:54:22,064 - 127.0.0.1 - ERROR [org.apache.velocity.rendering:1156] - Variable $org has not been set at 58f40468-c3d4-4270-8291-ab0b217229f1[line 1, column 16]
2021-12-07 14:54:22,066 - 127.0.0.1 - ERROR [net.shibboleth.idp.attribute.resolver.ad.impl.TemplateAttributeDefinition:200] - Attribute Definition 'mail': Unable to evaluate velocity template: Velocity template 58f40468-c3d4-4270-8291-ab0b217229f1 threw an exception
2021-12-07 14:54:22,067 - 127.0.0.1 - ERROR [net.shibboleth.idp.profile.impl.ResolveAttributes:300] - Profile Action ResolveAttributes: Error resolving attributes
net.shibboleth.idp.attribute.resolver.ResolutionException: Unable to evaluate template
	at net.shibboleth.idp.attribute.resolver.ad.impl.TemplateAttributeDefinition.doAttributeDefinitionResolve(TemplateAttributeDefinition.java:201)
Caused by: org.apache.velocity.exception.VelocityException: Velocity template 58f40468-c3d4-4270-8291-ab0b217229f1 threw an exception
	at net.shibboleth.utilities.java.support.velocity.Template.merge(Template.java:238)
Caused by: org.apache.velocity.exception.MethodInvocationException: Variable $org has not been set at 58f40468-c3d4-4270-8291-ab0b217229f1[line 1, column 16]
	at org.apache.velocity.runtime.parser.node.ASTReference.getRootVariableValue(ASTReference.java:1160)

you should not that these settings are global to all uses of velocity in the IdP except for view resolution: uses include:

* Attribute resolver (Template Attribute & HTTP, LDAP, RDBMS & StorageService DataConnector)
* Dynamic HTTP Metadata Provider
* SAML Post (encoders)
* LDAP Authn

If you need this to be more targetted that you will need to specify a velocityEngine=beanName in your Templated Attribute Defn (raise a support call if you need a hand building the bean).

V4.2 plans
----------

I’ll add a property ( idp.velocity.property.runtime.strictmode or some such) to do the heavy lifting

( https://shibboleth.atlassian.net/browse/IDP-1881#add-comment?atlOrigin=eyJpIjoiMTVhNGU4MDAyMWE2NGM0Zjg0Mjc1YTgwZmFlMjZmODciLCJwIjoiaiJ9 ) Add Comment ( https://shibboleth.atlassian.net/browse/IDP-1881#add-comment?atlOrigin=eyJpIjoiMTVhNGU4MDAyMWE2NGM0Zjg0Mjc1YTgwZmFlMjZmODciLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100183- sha1:f6eba4b )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/commits/attachments/20211207/0de413a9/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-comment-icon-4491f765-a1e7-41aa-8dd4-400d4d03f28e
Type: image/png
Size: 1084 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20211207/0de413a9/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-avatar-293c50fe-75b8-48d8-8c84-7ced8141b2a6
Type: image/png
Size: 457 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20211207/0de413a9/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-footer-desktop-logo-39ee956b-b2ce-4786-a1d7-cbe2a16f1d43
Type: image/png
Size: 10805 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20211207/0de413a9/attachment-0005.png>


More information about the commits mailing list