java 基于UI的Pac4j客户端编辑配置

ulydmbyx  于 7个月前  发布在  Java
关注(0)|答案(1)|浏览(62)

我使用Pac4j 5.0X与Java 8 Jee项目,这是基于maven的。供参考::https://github.com/pac4j/jee-pac4j-demo/tree/5.0.x在这方面,我使用Webservlet编辑配置更改

@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 profile");
                }
            } catch (Exception e) {
                
            }
        });

    }
}

字符串
这是一个示例测试,我正在修改Democracy Factory当我重新启动我的应用程序时,默认的一个被加载,我可以看到authorize call sent openid作为默认范围,当我点击customScopes servlet时,范围现在被设置为openid profile,它在应用程序中#refecte,[The Default Scopes is Openid ],现在我第二次再次击中#endpoint,范围没有改变,范围是openid配置文件,现在应该是openid #v,但我看不到auth端点发送openid,它仍然反映openid配置文件,而登录。
每当我改变我的配置从UI中的插件应该相应地更新每一次。

8gsdolmq

8gsdolmq1#

你不应该这样做,我的意思是,随着时间的推移改变配置。
要么你需要两个具有不同作用域的GoogleOidcClient,要么你需要在代码中进行自定义。

相关问题