Search in sources :

Example 1 with SCIMSettings

use of io.gravitee.am.model.scim.SCIMSettings in project gravitee-access-management by gravitee-io.

the class MongoDomainRepository method convert.

private static SCIMSettings convert(SCIMSettingsMongo scimMongo) {
    if (scimMongo == null) {
        return null;
    }
    SCIMSettings scimSettings = new SCIMSettings();
    scimSettings.setEnabled(scimMongo.isEnabled());
    scimSettings.setIdpSelectionEnabled(scimMongo.isIdpSelectionEnabled());
    scimSettings.setIdpSelectionRule(scimMongo.getIdpSelectionRule());
    return scimSettings;
}
Also used : SCIMSettings(io.gravitee.am.model.scim.SCIMSettings)

Example 2 with SCIMSettings

use of io.gravitee.am.model.scim.SCIMSettings in project gravitee-access-management by gravitee-io.

the class PatchDomainTest method testGetRequiredPermissions.

@Test
public void testGetRequiredPermissions() {
    PatchDomain patchDomain = new PatchDomain();
    assertEquals(Collections.emptySet(), patchDomain.getRequiredPermissions());
    patchDomain.setName(Optional.of("patchName"));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    patchDomain.setDescription(Optional.of("patchDescription"));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    patchDomain.setEnabled(Optional.of(true));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    patchDomain.setPath(Optional.of("patchPath"));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    patchDomain.setLoginSettings(Optional.of(new LoginSettings()));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    patchDomain.setAccountSettings(Optional.of(new AccountSettings()));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    patchDomain.setTags(Optional.of(Collections.singleton("patchTag")));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    PatchOIDCSettings oidcSettings = new PatchOIDCSettings();
    patchDomain.setOidc(Optional.of(oidcSettings));
    assertEquals(Collections.emptySet(), patchDomain.getRequiredPermissions());
    oidcSettings.setClientRegistrationSettings(Optional.of(new PatchClientRegistrationSettings()));
    oidcSettings.setRedirectUriStrictMatching(Optional.of(true));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_OPENID)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    patchDomain.setScim(Optional.of(new SCIMSettings()));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SCIM)), patchDomain.getRequiredPermissions());
    patchDomain = new PatchDomain();
    patchDomain.setUma(Optional.of(new UMASettings()));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_UMA)), patchDomain.getRequiredPermissions());
    // Check multiple permissions.
    patchDomain = new PatchDomain();
    patchDomain.setPath(Optional.of("patchPath"));
    patchDomain.setOidc(Optional.of(oidcSettings));
    patchDomain.setScim(Optional.of(new SCIMSettings()));
    assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS, Permission.DOMAIN_OPENID, Permission.DOMAIN_SCIM)), patchDomain.getRequiredPermissions());
}
Also used : AccountSettings(io.gravitee.am.model.account.AccountSettings) SCIMSettings(io.gravitee.am.model.scim.SCIMSettings) PatchOIDCSettings(io.gravitee.am.service.model.openid.PatchOIDCSettings) LoginSettings(io.gravitee.am.model.login.LoginSettings) PatchClientRegistrationSettings(io.gravitee.am.service.model.openid.PatchClientRegistrationSettings) UMASettings(io.gravitee.am.model.uma.UMASettings) Test(org.junit.Test)

Example 3 with SCIMSettings

use of io.gravitee.am.model.scim.SCIMSettings in project gravitee-access-management by gravitee-io.

the class DomainRepositoryTest method initDomain.

private Domain initDomain(String name) {
    Domain domain = new Domain();
    domain.setName(name);
    domain.setHrid(name);
    domain.setCreatedAt(new Date());
    domain.setUpdatedAt(domain.getCreatedAt());
    domain.setDescription(name + " description");
    domain.setEnabled(true);
    domain.setAlertEnabled(false);
    domain.setPath("/" + name);
    domain.setReferenceId("refId" + name);
    domain.setReferenceType(ReferenceType.ENVIRONMENT);
    domain.setVhostMode(true);
    VirtualHost host = new VirtualHost();
    host.setHost("hostname-" + name);
    host.setPath("/hostname-" + name);
    host.setOverrideEntrypoint(true);
    VirtualHost host2 = new VirtualHost();
    host2.setHost("hostname2-" + name);
    host2.setPath("/hostname2-" + name);
    host2.setOverrideEntrypoint(true);
    domain.setVhosts(Arrays.asList(host, host2));
    domain.setTags(new HashSet<>(Arrays.asList("tag1", "tag2")));
    domain.setIdentities(new HashSet<>(Arrays.asList("id1", "id2")));
    domain.setAccountSettings(new AccountSettings());
    domain.setLoginSettings(new LoginSettings());
    final OIDCSettings oidc = new OIDCSettings();
    final CIBASettings cibaSettings = new CIBASettings();
    cibaSettings.setEnabled(true);
    final CIBASettingNotifier notifier = new CIBASettingNotifier();
    notifier.setId(UUID.randomUUID().toString());
    cibaSettings.setDeviceNotifiers(Arrays.asList(notifier));
    oidc.setCibaSettings(cibaSettings);
    domain.setOidc(oidc);
    domain.setScim(new SCIMSettings());
    domain.setUma(new UMASettings());
    domain.setWebAuthnSettings(new WebAuthnSettings());
    domain.setSelfServiceAccountManagementSettings(new SelfServiceAccountManagementSettings());
    return domain;
}
Also used : SCIMSettings(io.gravitee.am.model.scim.SCIMSettings) CIBASettings(io.gravitee.am.model.oidc.CIBASettings) OIDCSettings(io.gravitee.am.model.oidc.OIDCSettings) WebAuthnSettings(io.gravitee.am.model.login.WebAuthnSettings) UMASettings(io.gravitee.am.model.uma.UMASettings) AccountSettings(io.gravitee.am.model.account.AccountSettings) CIBASettingNotifier(io.gravitee.am.model.oidc.CIBASettingNotifier) SelfServiceAccountManagementSettings(io.gravitee.am.model.SelfServiceAccountManagementSettings) LoginSettings(io.gravitee.am.model.login.LoginSettings) VirtualHost(io.gravitee.am.model.VirtualHost) Domain(io.gravitee.am.model.Domain)

Example 4 with SCIMSettings

use of io.gravitee.am.model.scim.SCIMSettings in project gravitee-access-management by gravitee-io.

the class CreateUserEndpointHandlerTest method shouldUseASelectedIdp.

@Test
public void shouldUseASelectedIdp() throws Exception {
    SCIMSettings scimSettings = mock(SCIMSettings.class);
    when(scimSettings.isIdpSelectionEnabled()).thenReturn(true);
    when(scimSettings.getIdpSelectionRule()).thenReturn("{#context.attributes['token']['idp']}");
    when(domain.getScim()).thenReturn(scimSettings);
    router.route("/Users").handler(rc -> {
        JWT token = new JWT();
        token.put("idp", "123456");
        rc.put(ConstantKeys.TOKEN_CONTEXT_KEY, token);
        rc.next();
    });
    router.route("/Users").handler(usersEndpoint::create);
    when(userService.create(any(), eq("123456"), any(), any())).thenReturn(Single.just(getUser()));
    testRequest(HttpMethod.POST, "/Users", req -> {
        req.setChunked(true);
        req.write(Json.encode(getUser()));
    }, 201, "Created", null);
}
Also used : SCIMSettings(io.gravitee.am.model.scim.SCIMSettings) JWT(io.gravitee.am.common.jwt.JWT) Test(org.junit.Test)

Example 5 with SCIMSettings

use of io.gravitee.am.model.scim.SCIMSettings in project gravitee-access-management by gravitee-io.

the class UpdateUserEndpointHandlerTest method shouldUseASelectedIdp.

@Test
public void shouldUseASelectedIdp() throws Exception {
    SCIMSettings scimSettings = mock(SCIMSettings.class);
    when(scimSettings.isIdpSelectionEnabled()).thenReturn(true);
    when(scimSettings.getIdpSelectionRule()).thenReturn("{#context.attributes['token']['idp']}");
    when(domain.getScim()).thenReturn(scimSettings);
    router.route("/Users").handler(userEndpoint::update);
    when(userService.update(any(), any(), eq("123456"), any(), any())).thenReturn(Single.just(getUser()));
    testRequest(HttpMethod.PUT, "/Users", req -> {
        req.setChunked(true);
        req.write(Json.encode(getUser()));
    }, 200, "OK", null);
}
Also used : SCIMSettings(io.gravitee.am.model.scim.SCIMSettings) Test(org.junit.Test)

Aggregations

SCIMSettings (io.gravitee.am.model.scim.SCIMSettings)6 AccountSettings (io.gravitee.am.model.account.AccountSettings)3 LoginSettings (io.gravitee.am.model.login.LoginSettings)3 Test (org.junit.Test)3 OIDCSettings (io.gravitee.am.model.oidc.OIDCSettings)2 UMASettings (io.gravitee.am.model.uma.UMASettings)2 JWT (io.gravitee.am.common.jwt.JWT)1 Domain (io.gravitee.am.model.Domain)1 SelfServiceAccountManagementSettings (io.gravitee.am.model.SelfServiceAccountManagementSettings)1 VirtualHost (io.gravitee.am.model.VirtualHost)1 WebAuthnSettings (io.gravitee.am.model.login.WebAuthnSettings)1 CIBASettingNotifier (io.gravitee.am.model.oidc.CIBASettingNotifier)1 CIBASettings (io.gravitee.am.model.oidc.CIBASettings)1 PatchDomain (io.gravitee.am.service.model.PatchDomain)1 PatchClientRegistrationSettings (io.gravitee.am.service.model.openid.PatchClientRegistrationSettings)1 PatchOIDCSettings (io.gravitee.am.service.model.openid.PatchOIDCSettings)1 Date (java.util.Date)1