Help with Custom Authentication using a Groovy script


I am attempting to write a Groovy script to authenticate against our institution’s SSO server. The Groovy Authenticator documentation simply states:

Then put some Groovy code in a wiki page that returns a XWikiAuthService object.

Based on this I wrote a Groovy script which extends the XWikiAuthServiceImpl class and returns a new instance. This validates and runs in-page but it generates a runtime exception when it’s loaded by the Groovy Authenticator (GroovyAuthServiceImpl class). Here is the output from the log file:

Ambiguous expression could be either a parameterless closure expression or an isolated open code block;
solution: Add an explicit closure parameter list, e.g. {it → …}, or force it to be treated as an open block by giving it a label, e.g. L:{…} @ line 1, column 1.

I’ve looked everywhere but I can’t find even the simplest working example of how to use the Groovy Authenticator. Any help with this is greatly appreciated.

I think the GroovyAuthServiceImpl expect a plain Groovy script. {{groovy}} is not really a Groovy script but a wiki macro which happen to contain a Groovy script.

That being said, I would really recommend implementing your authenticator as a JAR. Feels a lot less fragile than a wiki page and an authenticator is pretty critical.