use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method testSignaturesRequired.
@Test
public void testSignaturesRequired() throws Exception {
OIDCClientRepresentation clientRep = null;
OIDCClientRepresentation response = null;
try {
clientRep = createRep();
clientRep.setUserinfoSignedResponseAlg(Algorithm.ES256.toString());
clientRep.setRequestObjectSigningAlg(Algorithm.ES256.toString());
response = reg.oidc().create(clientRep);
Assert.assertEquals(Algorithm.ES256.toString(), response.getUserinfoSignedResponseAlg());
Assert.assertEquals(Algorithm.ES256.toString(), response.getRequestObjectSigningAlg());
Assert.assertNotNull(response.getClientSecret());
// Test Keycloak representation
ClientRepresentation kcClient = getClient(response.getClientId());
OIDCAdvancedConfigWrapper config = OIDCAdvancedConfigWrapper.fromClientRepresentation(kcClient);
Assert.assertEquals(config.getUserInfoSignedResponseAlg(), Algorithm.ES256);
Assert.assertEquals(config.getRequestObjectSignatureAlg(), Algorithm.ES256);
// update (ES256 to PS256)
clientRep.setUserinfoSignedResponseAlg(Algorithm.PS256.toString());
clientRep.setRequestObjectSigningAlg(Algorithm.PS256.toString());
response = reg.oidc().create(clientRep);
Assert.assertEquals(Algorithm.PS256.toString(), response.getUserinfoSignedResponseAlg());
Assert.assertEquals(Algorithm.PS256.toString(), response.getRequestObjectSigningAlg());
// keycloak representation
kcClient = getClient(response.getClientId());
config = OIDCAdvancedConfigWrapper.fromClientRepresentation(kcClient);
Assert.assertEquals(config.getUserInfoSignedResponseAlg(), Algorithm.PS256);
Assert.assertEquals(config.getRequestObjectSignatureAlg(), Algorithm.PS256);
} finally {
// back to RS256 for other tests
clientRep.setUserinfoSignedResponseAlg(Algorithm.RS256.toString());
clientRep.setRequestObjectSigningAlg(Algorithm.RS256.toString());
response = reg.oidc().create(clientRep);
}
}
use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method createClientImplicitFlow.
@Test
public void createClientImplicitFlow() throws ClientRegistrationException {
OIDCClientRepresentation clientRep = createRep();
clientRep.setResponseTypes(Arrays.asList("id_token token"));
OIDCClientRepresentation response = reg.oidc().create(clientRep);
String clientId = response.getClientId();
ClientRepresentation kcClientRep = getKeycloakClient(clientId);
Assert.assertFalse(kcClientRep.isPublicClient());
Assert.assertNull(kcClientRep.getSecret());
}
use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method testTlsClientAuthSubjectDn.
@Test
public void testTlsClientAuthSubjectDn() throws Exception {
OIDCClientRepresentation response = null;
OIDCClientRepresentation updated = null;
try {
// create (no specification)
OIDCClientRepresentation clientRep = createRep();
clientRep.setTokenEndpointAuthMethod(OIDCLoginProtocol.TLS_CLIENT_AUTH);
clientRep.setTlsClientAuthSubjectDn("Ein");
response = reg.oidc().create(clientRep);
Assert.assertEquals(OIDCLoginProtocol.TLS_CLIENT_AUTH, response.getTokenEndpointAuthMethod());
Assert.assertEquals("Ein", response.getTlsClientAuthSubjectDn());
// Test Keycloak representation
ClientRepresentation kcClient = getClient(response.getClientId());
OIDCAdvancedConfigWrapper config = OIDCAdvancedConfigWrapper.fromClientRepresentation(kcClient);
Assert.assertEquals(X509ClientAuthenticator.PROVIDER_ID, kcClient.getClientAuthenticatorType());
Assert.assertEquals("Ein", config.getTlsClientAuthSubjectDn());
Assert.assertFalse(config.getAllowRegexPatternComparison());
// update
reg.auth(Auth.token(response));
response.setTlsClientAuthSubjectDn("(.*?)(?:$)");
updated = reg.oidc().update(response);
Assert.assertEquals(OIDCLoginProtocol.TLS_CLIENT_AUTH, updated.getTokenEndpointAuthMethod());
Assert.assertEquals("(.*?)(?:$)", updated.getTlsClientAuthSubjectDn());
// Test Keycloak representation
kcClient = getClient(updated.getClientId());
config = OIDCAdvancedConfigWrapper.fromClientRepresentation(kcClient);
Assert.assertEquals(X509ClientAuthenticator.PROVIDER_ID, kcClient.getClientAuthenticatorType());
Assert.assertEquals("(.*?)(?:$)", config.getTlsClientAuthSubjectDn());
} finally {
// revert
reg.auth(Auth.token(updated));
updated.setTokenEndpointAuthMethod(null);
updated.setTlsClientAuthSubjectDn(null);
reg.oidc().update(updated);
}
}
use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method createRep.
private OIDCClientRepresentation createRep() {
OIDCClientRepresentation client = new OIDCClientRepresentation();
client.setClientName("RegistrationAccessTokenTest");
client.setClientUri("http://root");
client.setRedirectUris(Collections.singletonList("http://redirect"));
client.setFrontChannelLogoutUri("http://frontchannel");
return client;
}
use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method testOIDCEndpointGetWithSamlClient.
@Test
public void testOIDCEndpointGetWithSamlClient() throws Exception {
OIDCClientRepresentation response = create();
reg.auth(Auth.token(response));
assertNotNull(reg.oidc().get(response.getClientId()));
ClientsResource clientsResource = adminClient.realm(TEST).clients();
ClientRepresentation client = clientsResource.findByClientId(response.getClientId()).get(0);
// change client to saml
client.setProtocol("saml");
clientsResource.get(client.getId()).update(client);
assertGetFail(client.getClientId(), 400, Errors.INVALID_CLIENT);
}
Aggregations