Refine search
new Clients(URI.create(conf.getString("pac4j.callback.url")).normalize().toString(), new ArrayList<>())); pac4j.setHttpActionAdapter(new Pac4jActionAdapter()); List<Client> clientList = new ArrayList<>(clients.getClients()); if (clientList.size() == 0 && this.clients.size() == 0) { .collect(Collectors.toList()); securityRoutes.forEach(it -> clientList.add(it.client)); clients.setClients(clientList); pac4j.setSecurityLogic(securityLogic); Map<String, Pac4jSecurityFilter> filters = new LinkedHashMap<>(); patterns.add(callbackPath); securityRoutes.forEach(it -> {
WebContext ctx = req.require(WebContext.class); List<Client> clientList = clients.findAllClients(); Client client = clientList.size() == 1 ? clientList.get(0) : clients.findClient(ctx); String id = profile.getId(); req.set(Auth.ID, id); session.set(Auth.ID, id);
@Inject public ClientsProvider(@Named("auth.callback") final String callback, final Set<Client> clients) { this.clients = new Clients(callback, ImmutableList.copyOf(clients)); }
protected Client getClient(JaxrsWebContext context) { try { return clients.findClient(context); } catch (TechnicalException e) { logger.debug("Error while getting the client from the context", e); return null; } }
oidcClient.setAuthorizationGenerator((ctx, profile) -> { profile.addRole("ROLE_ADMIN"); return profile; }); final String token = ((TokenCredentials) credentials).getToken(); if (CommonHelper.isNotBlank(token)) { final CommonProfile profile = new CommonProfile(); profile.setId(token); credentials.setUserProfile(profile); final Clients clients = new Clients("http://localhost:8080/callback", oidcClient, saml2Client, facebookClient, twitterClient, formClient, indirectBasicAuthClient, casClient, parameterClient, directBasicAuthClient, new AnonymousClient(), headerClient);
samlCfg.setDestinationBindingType(SAMLConstants.SAML2_REDIRECT_BINDING_URI); SAML2Client saml2Client = new SAML2Client(samlCfg); Clients clients = new Clients(config.getStringOrThrow("public.url") + "/saml-callback", saml2Client); final org.pac4j.core.config.Config pac4jConfig = new org.pac4j.core.config.Config(clients); SecurityHandlerOptions options = new SecurityHandlerOptions().withClients("SAML2Client"); clients.findClient("SAML2Client");
@Bean protected Clients clients() { //可以设置默认client Clients clients = new Clients(); //支持的client全部设置进去 clients.setClients(casClient(), casRestFormClient()); return clients; }
default Config getConfig() { // login not used because the ajax resolver always answer true Authenticator<UsernamePasswordCredentials> auth = new SimpleTestUsernamePasswordAuthenticator(); FormClient client = new FormClient("notUsedLoginUrl", auth); DirectFormClient client2 = new DirectFormClient(auth); DirectFormClient client3 = new DirectFormClient(auth); client3.setName(DEFAULT_CLIENT); Clients clients = new Clients("notUsedCallbackUrl", client, client2, client3); // in case of invalid credentials, we simply want the error, not a redirect to the login url clients.setAjaxRequestResolver(new JaxRsAjaxRequestResolver()); // so that callback url have the correct prefix w.r.t. the container's context clients.setUrlResolver(new JaxRsUrlResolver()); clients.setDefaultSecurityClients(DEFAULT_CLIENT); return new Config(clients); } }
final Map<String, CommonProfile> indirectProfiles = pac4jUser.pac4jUserProfiles().entrySet().stream() .filter(e -> { final String clientName = e.getValue().getClientName(); return (config.getClients().findClient(clientName) instanceof IndirectClient); }) .collect(toMap(e -> e.getKey(), e -> e.getValue()));
@SuppressWarnings("unchecked") protected AuthenticationInfo internalClientGetAuthenticationInfo(final AuthenticationToken authenticationToken) { final UsernamePasswordAndClientToken clientToken = (UsernamePasswordAndClientToken) authenticationToken; log.debug("clientToken : {}", clientToken); if (clientToken == null) { return null; } final Credentials credentials = (Credentials) clientToken.getCredentials(); log.debug("credentials : {}", credentials); final Client<Credentials, CommonProfile> client = this.clients.findClient(clientToken.getClientName()); log.debug("client : {}", client); final CommonProfile profile = client.getUserProfile(credentials, clientToken.getContext()); log.debug("profile : {}", profile); if (profile == null) { final String message = "No profile retrieved from authentication using client : " + client + " and credentials : " + credentials; log.info(message); throw new AuthenticationException(message); } // refresh authentication token with user id final String userId = profile.getTypedId(); clientToken.setUserId(userId); // set rememberMe status clientToken.setRememberMe(profile.isRemembered()); return internalClientGetAuthenticationInfo(profile, credentials); }
private static String getClientNames(final Config config) { return config.getClients().getClients().stream().map(Client::getName).collect(Collectors.joining(Pac4jConstants.ELEMENT_SEPRATOR)); }
public CallbackDeployingPac4jAuthHandler(final Vertx vertx, final SessionStore<VertxWebContext> sessionStore, final Config config, final Router router, final Pac4jAuthProvider authProvider, final SecurityHandlerOptions options, final CallbackHandlerOptions callbackOptions) { super(vertx, sessionStore, config, authProvider, options); // Other null checks performed by parent class CommonHelper.assertNotNull("router", router); CommonHelper.assertNotBlank("callbackUrl", config.getClients().getCallbackUrl()); final URI uri; try { uri = new URI(config.getClients().getCallbackUrl()); } catch (URISyntaxException e) { LOG.error(e.getMessage()); throw toTechnicalException(e); } // Start manager verticle router.route(HttpMethod.GET, uri.getPath()).handler(authResultHandler(vertx, sessionStore, config, callbackOptions)); }
@ConditionalOnMissingBean(name = "pac4jAuthenticationEventExecutionPlanConfigurer") @Bean public AuthenticationEventExecutionPlanConfigurer pac4jAuthenticationEventExecutionPlanConfigurer() { return plan -> { if (!builtClients().findAllClients().isEmpty()) { LOGGER.info("Registering delegated authentication clients..."); plan.registerAuthenticationHandlerWithPrincipalResolver(clientAuthenticationHandler(), defaultPrincipalResolver.getIfAvailable()); plan.registerAuthenticationMetadataPopulator(clientAuthenticationMetaDataPopulator()); } }; }
var Client = Backbone.Model.extend({}); var Clients = Backbone.Collection.extend({ model: Client }); var clients = new Clients();
protected Client getClient(Session session) { String clientName = session.getAttribute(Clients.DEFAULT_CLIENT_NAME_PARAMETER); if (Strings.isNullOrEmpty(clientName)) { return null; } return clients.findClient(clientName); }
@Bean public Clients clients() { // 设置默认client Clients clients = new Clients(); // token校验器,可以用HeaderClient更安全 ParameterClient parameterClient = new ParameterClient("token", jwtAuthenticator); parameterClient.setSupportGetRequest(true); parameterClient.setName("jwt"); // 支持的client全部设置进去 clients.setClients(casClient(), casRestFormClient(), parameterClient); return clients; }
final Map<String, CommonProfile> indirectProfiles = pac4jUser.pac4jUserProfiles().entrySet().stream() .filter(e -> { final String clientName = e.getValue().getClientName(); return (config.getClients().findClient(clientName) instanceof IndirectClient); }) .collect(toMap(e -> e.getKey(), e -> e.getValue()));
final List<Client> clients = config.getClients().getClients(); if (clients == null || clients.isEmpty()) { log.atLeastOnePac4jClientMustBeDefined();
public CallbackDeployingPac4jAuthHandler(final Vertx vertx, final SessionStore<VertxWebContext> sessionStore, final Config config, final Router router, final Pac4jAuthProvider authProvider, final SecurityHandlerOptions options, final CallbackHandlerOptions callbackOptions) { super(vertx, sessionStore, config, authProvider, options); // Other null checks performed by parent class CommonHelper.assertNotNull("router", router); CommonHelper.assertNotBlank("callbackUrl", config.getClients().getCallbackUrl()); final URI uri; try { uri = new URI(config.getClients().getCallbackUrl()); } catch (URISyntaxException e) { LOG.error(e.getMessage()); throw toTechnicalException(e); } // Start manager verticle router.route(HttpMethod.GET, uri.getPath()).handler(authResultHandler(vertx, sessionStore, config, callbackOptions)); }
/** * @param callbackUrl * @param clients */ public SecurityPlugin(String callbackUrl, Client... clients) { this.clients = new Clients(callbackUrl, clients); }