Pac4j Editing Configuration of a Client Based on UI

77 views Asked by At

I am Using Pac4j 5.0X with Java 8 Jee Project which is maven based. For reference:: https://github.com/pac4j/jee-pac4j-demo/tree/5.0.x In this ,I am using Webservlet for editing the Config changees

@WebServlet(urlPatterns = "/customScopes")
public class CustomScopesServlet2 extends HttpServlet {
   Integer counter=0;
    @Override
    public void init() throws ServletException {
        super.init();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        OidcConfiguration oidcConfiguration = new OidcConfiguration();
        oidcConfiguration.setClientId("");
        oidcConfiguration.setSecret("");
        oidcConfiguration.setUseNonce(false);
        DemoConfigFactory.CONFIG_INSTANCE.getClients().getClients().forEach(client -> {
            try {
                counter++;
                if (client instanceof GoogleOidcClient) {
                    ((GoogleOidcClient) client).setConfiguration(oidcConfiguration);
                    String name = client.getName();
                     if(counter==1)
                      ((GoogleOidcClient) client).getConfiguration().setScope("openid profile");
                     else if(counter>1)
                      ((GoogleOidcClient) client).getConfiguration().setScope("openid");
                }
            } catch (Exception e) {
                
            }
        });

    }
}

This is a Sample Test where i am modifying the DemoconfigFaactory When i restart my app, the default one is loaded and i can see authorize call sent openid as default scope, when i hit customScopes servlet the scopes are now set to openid profile and it #refecte's in the application , [The Default Scopes is Openid ], now the second time i hit the #endpoint again the scopes is not changed scopes which was openid profile ,should now be openid #vbut i cant see the auth endpoint to send openid it still refects openid profile while loggig in.

Whenever i change my configuration from the UI the configs should be updated accordingly each time.

1

There are 1 answers

6
jleleu On

You shouldn't do that, I mean, changing configuration over time.

Either you need two GoogleOidcClient with different scopes or you need a customisation in the code.