#1 2017-08-29 06:30:54

sateesh.nvl
Member
Registered: 2017-08-29

Unable to access URL parameters in a custom PAM script

Hi,
I am trying to set up an SSO integration and attempted with a very simple script to test it out.  However, the following script does not seem to read parameters passed in URL.

The URL I am using to access report server is this:  http://localhost:8080/?ssouser=root

Please note that the script works fine if I directly pass the username as string
The code in my script is this:

import net.datenwerke.security.service.authenticator.ReportServerPAM;
import net.datenwerke.rs.authenticator.client.login.dto.UserPasswordAuthToken;
import net.datenwerke.security.service.authenticator.AuthenticationResult;
import net.datenwerke.security.service.usermanager.UserManagerService;
import net.datenwerke.security.service.authenticator.hooks.PAMHook;
import net.datenwerke.security.service.authenticator.hooks.adapter.PAMHookAdapter;
import javax.servlet.http.HttpServletRequest;


def userService = GLOBALS.getInstance(UserManagerService.class);

def requestProvider = GLOBALS.getProvider(HttpServletRequest.class);
HttpServletRequest req = requestProvider.get();
def ssouser = req.getParameter('ssouser');

/* the below line works, but not the above dynamic variable */
/* def ssouser = "root" */

def customPAM = [
  authenticate : { tokens ->
    return new AuthenticationResult(true, userService.getUserByName(ssouser)); // login the root
  },
  getClientModuleName : { return "net.datenwerke.rs.authenticator.client.login.pam.UserPasswordClientPAM"; }
] as ReportServerPAM;

def callback = [
  afterStaticPamConfig : {pams ->
    pams.clear();
    pams.add(customPAM);
  }
] as PAMHookAdapter;

GLOBALS.services.callbackRegistry.attachHook("MY_CUSTOM_AUTHENTICATOR", PAMHook.class, callback);

Any help is greatly appreciated. Thanks

Offline

#2 2017-09-03 15:46:20

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Unable to access URL parameters in a custom PAM script

Hi sateesh.nvl,

I'm afraid url parameters are not available with PAM scripts, as explained here: https://forum.reportserver.net/viewtopic.php?id=297, #7.
Could you use an approach similar as the one stated in #7 ? It should work using redirection.

Best regards,
Eduardo

Offline

Board footer

Powered by FluxBB