use of com.evolveum.midpoint.authentication.api.IdentityProvider in project midpoint by Evolveum.
the class AbstractPageRemoteAuthenticationSelect method initCustomLayer.
@Override
protected void initCustomLayer() {
List<IdentityProvider> providers = getProviders();
add(new ListView<IdentityProvider>(ID_PROVIDERS, providers) {
@Override
protected void populateItem(ListItem<IdentityProvider> item) {
item.add(new ExternalLink(ID_PROVIDER, item.getModelObject().getRedirectLink(), item.getModelObject().getLinkText()));
}
});
MidpointForm<?> form = new MidpointForm<>(ID_LOGOUT_FORM);
ModuleAuthentication actualModule = AuthUtil.getProcessingModuleIfExist();
if (actualModule != null) {
Authentication actualAuthentication = actualModule.getAuthentication();
String authName = actualModule.getNameOfModuleType();
form.add(new VisibleBehaviour(() -> existRemoteAuthentication(actualAuthentication, authName)));
String prefix = actualModule.getPrefix();
form.add(AttributeModifier.replace("action", (IModel<String>) () -> existRemoteAuthentication(actualAuthentication, authName) ? SecurityUtils.getPathForLogoutWithContextPath(getRequest().getContextPath(), prefix) : ""));
} else {
form.add(new VisibleBehaviour(() -> false));
}
add(form);
WebMarkupContainer csrfField = SecurityUtils.createHiddenInputForCsrf(ID_CSRF_FIELD);
form.add(csrfField);
}
use of com.evolveum.midpoint.authentication.api.IdentityProvider in project midpoint by Evolveum.
the class OidcClientModuleFactory method createEmptyModuleAuthentication.
public ModuleAuthenticationImpl createEmptyModuleAuthentication(OidcClientModuleWebSecurityConfiguration configuration, ServletRequest request) {
OidcClientModuleAuthenticationImpl moduleAuthentication = new OidcClientModuleAuthenticationImpl();
List<IdentityProvider> providers = new ArrayList<>();
configuration.getClientRegistrationRepository().forEach(client -> {
String authRequestPrefixUrl = request.getServletContext().getContextPath() + configuration.getPrefixOfModule() + OidcClientModuleAuthenticationImpl.AUTHORIZATION_REQUEST_PROCESSING_URL_SUFFIX_WITH_REG_ID;
IdentityProvider mp = new IdentityProvider().setLinkText(client.getClientName()).setRedirectLink(authRequestPrefixUrl.replace("{registrationId}", client.getRegistrationId()));
providers.add(mp);
});
moduleAuthentication.setClientsRepository(configuration.getClientRegistrationRepository());
moduleAuthentication.setProviders(providers);
moduleAuthentication.setNameOfModule(configuration.getNameOfModule());
moduleAuthentication.setPrefix(configuration.getPrefixOfModule());
return moduleAuthentication;
}
use of com.evolveum.midpoint.authentication.api.IdentityProvider in project midpoint by Evolveum.
the class AbstractPageRemoteAuthenticationSelect method getProviders.
private List<IdentityProvider> getProviders() {
List<IdentityProvider> providers = new ArrayList<>();
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
ModuleAuthentication moduleAuthentication = mpAuthentication.getProcessingModuleAuthentication();
if (moduleAuthentication instanceof RemoteModuleAuthentication) {
providers = ((RemoteModuleAuthentication) moduleAuthentication).getProviders();
if (providers.isEmpty()) {
String key = getErrorKeyEmptyProviders();
error(getString(key));
}
return providers;
}
String key = getErrorKeyUnsupportedType();
error(getString(key));
return providers;
}
String key = "web.security.flexAuth.unsupported.auth.type";
error(getString(key));
return providers;
}
use of com.evolveum.midpoint.authentication.api.IdentityProvider in project midpoint by Evolveum.
the class Saml2ModuleFactory method createEmptyModuleAuthentication.
public ModuleAuthenticationImpl createEmptyModuleAuthentication(SamlModuleWebSecurityConfiguration configuration, ServletRequest request) {
Saml2ModuleAuthenticationImpl moduleAuthentication = new Saml2ModuleAuthenticationImpl();
List<IdentityProvider> providers = new ArrayList<>();
configuration.getRelyingPartyRegistrationRepository().forEach(p -> {
String authRequestPrefixUrl = request.getServletContext().getContextPath() + configuration.getPrefixOfModule() + RemoteModuleAuthenticationImpl.AUTHENTICATION_REQUEST_PROCESSING_URL_SUFFIX_WITH_REG_ID;
SamlAdditionalConfiguration config = configuration.getAdditionalConfiguration().get(p.getRegistrationId());
IdentityProvider mp = new IdentityProvider().setLinkText(config.getLinkText()).setRedirectLink(authRequestPrefixUrl.replace("{registrationId}", p.getRegistrationId()));
providers.add(mp);
});
moduleAuthentication.setProviders(providers);
moduleAuthentication.setAdditionalConfiguration(configuration.getAdditionalConfiguration());
moduleAuthentication.setNameOfModule(configuration.getNameOfModule());
moduleAuthentication.setPrefix(configuration.getPrefixOfModule());
return moduleAuthentication;
}
use of com.evolveum.midpoint.authentication.api.IdentityProvider in project midpoint by Evolveum.
the class RemoteAuthenticationEntryPoint method commence.
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
ModuleAuthentication moduleAuthentication = mpAuthentication.getProcessingModuleAuthentication();
if (moduleAuthentication instanceof RemoteModuleAuthentication) {
List<IdentityProvider> providers = ((RemoteModuleAuthentication) moduleAuthentication).getProviders();
if (request.getSession().getAttribute("SPRING_SECURITY_LAST_EXCEPTION") == null) {
if (providers.size() == 1) {
response.sendRedirect(providers.get(0).getRedirectLink());
return;
}
} else if (getLoginFormUrl().equals(request.getServletPath()) && AuthenticationModuleState.LOGIN_PROCESSING.equals(moduleAuthentication.getState())) {
return;
}
}
}
super.commence(request, response, authException);
}
Aggregations