Pre-fill username field in login-form via GET parameter (using OIDC protocol)

18 views
Skip to first unread message

Christian Migowski

unread,
Jul 16, 2021, 2:26:09 AM7/16/21
to CAS Community
Hi,

is it possible to pre-fill the username field on the login form using the OIDC protocol?
I had a look at the template and there is a parameter openIdLocalId which enables this.

I created and configured the following LoginDecorator-Groovy script and it works as expected when calling the login endpoint directly: 

def run(Object[] args) {
    def requestContext = args[0]
    def applicationContext = args[1]
    def logger = args[2]

    // Url parameter can not be 'username' because cas uses this parameter
    String usrName = requestContext.getRequestParameters().get("usrName")
    if(usrName != null) {
        logger.info("using preset username from request parameters: " + usrName)
        requestContext.getFlowScope().put("openIdLocalId", usrName)
    }
}

Unfortunately when using OIDC the clients never call the /login endpoint directly but instead first call the /authorize endpoint, which then internally redirects to the /login endpoint - where unfortunately the additional request parameter gets lost, rendering the script effect-less.
I scanned through the code, read the documentation and searched the web but I couldnt find any information about it, the name "openIdLocalId" may imply that it's got something to do with OIDC but I really cannot figure out how to do it.

If there is another way to achieve this I would be happy to learn about it!

The usecase is that a client application requests the user to enter its username and then decides depending on this to which IdP ( i.e. there are multiple) the user will be redirected, the user shouldnt be required to enter his username again after the re-direct to the IdP.

Thanks and best regards,
christian
Reply all
Reply to author
Forward
0 new messages