Java Code Examples for org.keycloak.representations.idm.ClientRepresentation#setDirectAccessGrantsEnabled()
The following examples show how to use
org.keycloak.representations.idm.ClientRepresentation#setDirectAccessGrantsEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeycloakTestResource.java From quarkus with Apache License 2.0 | 6 votes |
private static ClientRepresentation createClient(String clientId) { ClientRepresentation client = new ClientRepresentation(); client.setClientId(clientId); client.setPublicClient(false); client.setSecret("secret"); client.setDirectAccessGrantsEnabled(true); client.setEnabled(true); client.setAuthorizationServicesEnabled(true); ResourceServerRepresentation authorizationSettings = new ResourceServerRepresentation(); authorizationSettings.setResources(new ArrayList<>()); authorizationSettings.setPolicies(new ArrayList<>()); configurePermissionResourcePermission(authorizationSettings); configureClaimBasedPermission(authorizationSettings); configureHttpResponseClaimBasedPermission(authorizationSettings); configureBodyClaimBasedPermission(authorizationSettings); configurePaths(authorizationSettings); client.setAuthorizationSettings(authorizationSettings); return client; }
Example 2
Source File: CustomFlowTest.java From keycloak with Apache License 2.0 | 6 votes |
@Override public void configureTestRealm(RealmRepresentation testRealm) { UserRepresentation user = UserBuilder.create() .username("login-test") .email("[email protected]") .enabled(true) .build(); testRealm.getUsers().add(user); // Set passthrough clientAuthenticator for our clients ClientRepresentation dummyClient = ClientBuilder.create() .clientId("dummy-client") .name("dummy-client") .authenticatorType(PassThroughClientAuthenticator.PROVIDER_ID) .directAccessGrants() .build(); testRealm.getClients().add(dummyClient); ClientRepresentation testApp = RealmRepUtil.findClientByClientId(testRealm, "test-app"); testApp.setClientAuthenticatorType(PassThroughClientAuthenticator.PROVIDER_ID); testApp.setDirectAccessGrantsEnabled(true); }
Example 3
Source File: KcOidcBrokerConfiguration.java From keycloak with Apache License 2.0 | 6 votes |
@Override public List<ClientRepresentation> createConsumerClients() { ClientRepresentation client = new ClientRepresentation(); client.setId("broker-app"); client.setClientId("broker-app"); client.setName("broker-app"); client.setSecret("broker-app-secret"); client.setEnabled(true); client.setDirectAccessGrantsEnabled(true); client.setRedirectUris(Collections.singletonList(getConsumerRoot() + "/auth/*")); client.setBaseUrl(getConsumerRoot() + "/auth/realms/" + REALM_CONS_NAME + "/app"); return Collections.singletonList(client); }
Example 4
Source File: AbstractClientTest.java From keycloak with Apache License 2.0 | 6 votes |
public static ClientRepresentation createClientRep(String clientId, String protocol) { ClientRepresentation client = new ClientRepresentation(); client.setClientId(clientId); client.setEnabled(true); client.setProtocol(protocol); client.setDirectAccessGrantsEnabled(true); client.setFullScopeAllowed(true); client.setPublicClient(true); client.setStandardFlowEnabled(true); if (protocol.equals(SAML)) { client.setAttributes(getSAMLAttributes()); } return client; }
Example 5
Source File: RealmSetup.java From keycloak-custom-protocol-mapper-example with Apache License 2.0 | 5 votes |
private List<ClientRepresentation> createClients() { ClientRepresentation client = new ClientRepresentation(); client.setEnabled(true); // normally you wouldn't do this, but we use the direct grant to be able // to fetch the token for demo purposes per curl ;-) client.setDirectAccessGrantsEnabled(true); client.setId(CLIENT); client.setName(CLIENT); client.setPublicClient(Boolean.TRUE); return Arrays.asList(client); }
Example 6
Source File: KeycloakRealmResourceManager.java From quarkus with Apache License 2.0 | 5 votes |
private static ClientRepresentation createClient(String clientId) { ClientRepresentation client = new ClientRepresentation(); client.setClientId(clientId); client.setPublicClient(false); client.setSecret("secret"); client.setDirectAccessGrantsEnabled(true); client.setEnabled(true); return client; }
Example 7
Source File: KeycloakTestResource.java From quarkus with Apache License 2.0 | 5 votes |
private static ClientRepresentation createClient(String clientId) { ClientRepresentation client = new ClientRepresentation(); client.setClientId(clientId); client.setPublicClient(false); client.setSecret("secret"); client.setDirectAccessGrantsEnabled(true); client.setEnabled(true); client.setAuthorizationServicesEnabled(true); ResourceServerRepresentation authorizationSettings = new ResourceServerRepresentation(); authorizationSettings.setResources(new ArrayList<>()); authorizationSettings.setPolicies(new ArrayList<>()); configurePermissionResourcePermission(authorizationSettings); configureClaimBasedPermission(authorizationSettings); configureHttpResponseClaimBasedPermission(authorizationSettings); configureBodyClaimBasedPermission(authorizationSettings); configurePaths(authorizationSettings); configureScopePermission(authorizationSettings); client.setAuthorizationSettings(authorizationSettings); return client; }
Example 8
Source File: KeycloakRealmResourceManager.java From quarkus with Apache License 2.0 | 5 votes |
private static ClientRepresentation createClient(String clientId) { ClientRepresentation client = new ClientRepresentation(); client.setClientId(clientId); client.setPublicClient(false); client.setSecret("secret"); client.setDirectAccessGrantsEnabled(true); client.setEnabled(true); client.setDefaultRoles(new String[] { "role-" + clientId }); if (clientId.startsWith("quarkus-app-webapp")) { client.setRedirectUris(Arrays.asList("*")); client.setDefaultClientScopes(Arrays.asList("microprofile-jwt")); } return client; }
Example 9
Source File: KeycloakDevModeRealmResourceManager.java From quarkus with Apache License 2.0 | 5 votes |
private static ClientRepresentation createClient(String clientId) { ClientRepresentation client = new ClientRepresentation(); client.setClientId(clientId); client.setPublicClient(true); client.setDirectAccessGrantsEnabled(true); client.setEnabled(true); client.setRedirectUris(Arrays.asList("*")); return client; }
Example 10
Source File: UserInfoTest.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void addTestRealms(List<RealmRepresentation> testRealms) { RealmRepresentation realmRepresentation = loadJson(getClass().getResourceAsStream("/testrealm.json"), RealmRepresentation.class); RealmBuilder realm = RealmBuilder.edit(realmRepresentation).testEventListener(); RealmRepresentation testRealm = realm.build(); testRealms.add(testRealm); ClientRepresentation samlApp = KeycloakModelUtils.createClient(testRealm, "saml-client"); samlApp.setSecret("secret"); samlApp.setServiceAccountsEnabled(true); samlApp.setDirectAccessGrantsEnabled(true); }
Example 11
Source File: GroupTest.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void addTestRealms(List<RealmRepresentation> testRealms) { RealmRepresentation testRealmRep = loadTestRealm(testRealms); testRealmRep.setEventsEnabled(true); List<UserRepresentation> users = testRealmRep.getUsers(); UserRepresentation user = new UserRepresentation(); user.setUsername("direct-login"); user.setEmail("direct-login@localhost"); user.setEnabled(true); List<CredentialRepresentation> credentials = new LinkedList<>(); CredentialRepresentation credential = new CredentialRepresentation(); credential.setType(CredentialRepresentation.PASSWORD); credential.setValue("password"); credentials.add(credential); user.setCredentials(credentials); users.add(user); List<ClientRepresentation> clients = testRealmRep.getClients(); ClientRepresentation client = new ClientRepresentation(); client.setClientId("resource-owner"); client.setDirectAccessGrantsEnabled(true); client.setSecret("secret"); clients.add(client); }
Example 12
Source File: OIDCClientRegistrationTest.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void addTestRealms(List<RealmRepresentation> testRealms) { super.addTestRealms(testRealms); RealmRepresentation testRealm = testRealms.get(0); testRealm.setPrivateKey(PRIVATE_KEY); testRealm.setPublicKey(PUBLIC_KEY); ClientRepresentation samlApp = KeycloakModelUtils.createClient(testRealm, "saml-client"); samlApp.setSecret("secret"); samlApp.setServiceAccountsEnabled(true); samlApp.setDirectAccessGrantsEnabled(true); }
Example 13
Source File: SAMLClientRegistrationTest.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void addTestRealms(List<RealmRepresentation> testRealms) { super.addTestRealms(testRealms); RealmRepresentation testRealm = testRealms.get(0); ClientRepresentation samlApp = KeycloakModelUtils.createClient(testRealm, "oidc-client"); samlApp.setSecret("secret"); samlApp.setServiceAccountsEnabled(true); samlApp.setDirectAccessGrantsEnabled(true); }
Example 14
Source File: AbstractAdminCrossDCTest.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void configureTestRealm(RealmRepresentation testRealm) { log.debug("Configuring test realm '" + testRealm.getRealm() + "'. Enabling direct access grant."); ClientRepresentation testApp = findTestApp(testRealm); if (testApp == null) { throw new IllegalStateException("Couldn't find the 'test-app' within the realm '" + testRealm.getRealm() + "'"); } testApp.setDirectAccessGrantsEnabled(true); }
Example 15
Source File: ClientManager.java From keycloak with Apache License 2.0 | 4 votes |
public void directAccessGrant(Boolean enable) { ClientRepresentation app = clientResource.toRepresentation(); app.setDirectAccessGrantsEnabled(enable); clientResource.update(app); }