{"id":22389736,"url":"https://github.com/entando/keycloak-connector","last_synced_at":"2025-03-26T21:27:00.048Z","repository":{"id":39955965,"uuid":"180158164","full_name":"entando/keycloak-connector","owner":"entando","description":"Generates client jar for interacting with keycloak architecture","archived":false,"fork":false,"pushed_at":"2023-07-22T02:31:51.000Z","size":115,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-01T03:27:41.836Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/entando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-08T13:44:07.000Z","updated_at":"2020-11-23T15:19:26.000Z","dependencies_parsed_at":"2025-02-01T03:26:28.353Z","dependency_job_id":"012e6600-c751-4572-a453-a072c747553d","html_url":"https://github.com/entando/keycloak-connector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entando%2Fkeycloak-connector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entando%2Fkeycloak-connector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entando%2Fkeycloak-connector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entando%2Fkeycloak-connector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/entando","download_url":"https://codeload.github.com/entando/keycloak-connector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245737890,"owners_count":20664180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-05T03:13:08.334Z","updated_at":"2025-03-26T21:27:00.025Z","avatar_url":"https://github.com/entando.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keycloak Connector\nGenerates client jar for interacting with keycloak architecture.\nThis repository consists of two modules, \n1. The core module with the keycloak-connector logic itself\n2. A testutils module with some utilities to use with Spring Test\n\n# Core Module\n\n## Installation\nJust add the dependency on your `pom.xml` file\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.entando\u003c/groupId\u003e\n    \u003cartifactId\u003ekeycloak-connector\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Configuration\nAdd these configurations to your `application.properties` file\n\n### To enable Keycloak security\n```\nkeycloak.enabled=true\nkeycloak.auth-server-url=${KEYCLOAK_AUTH_URL:http://keycloak.url.here/auth}\nkeycloak.realm=${KEYCLOAK_REALM:realm-here}\nkeycloak.resource=${KEYCLOAK_CLIENT_ID:client-id}\nkeycloak.credentials.secret=${KEYCLOAK_CLIENT_SECRET}\nkeycloak.ssl-required=external\nkeycloak.public-client=false\n```\n\n### Custom Keycloak configurations\n\n\u003e- `entando.keycloak.sessionStateful`: Mark as true if you want to use redirect and session directly through Java. Default: `false`\n\n### Exceptions\nThis project throw two exceptions.\n\n#### org.entando.keycloak.ForbiddenException\nThrown when the user doesn't have rights to execute an operation.\n\n#### org.entando.keycloak.UnauthorizedException\nThrown when no credential is provided on a secured endpoint.\n\n### Resolvers\nIt's possible to inject the authenticated user to the controller you are developing.\nJust add `AuthenticatedUser` argument to your endpoint method.\n\n# Test utilities module\nThis modules contains some utilities class to enable integration tests when using keycloak-connector\n\n## Installation\nJust add the dependency on your `pom.xml` file\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.entando\u003c/groupId\u003e\n    \u003cartifactId\u003ekeycloak-connector-testutils\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0-SNAPSHOT\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n## Configuration\nAdd these configurations to your `application.properties` file\n\n### To enable Keycloak security\n```\nkeycloak.enabled=true\nkeycloak.auth-server-url=${KEYCLOAK_AUTH_URL:http://keycloak.url.here/auth}\nkeycloak.realm=${KEYCLOAK_REALM:realm-here}\nkeycloak.resource=${KEYCLOAK_CLIENT_ID:client-id}\nkeycloak.credentials.secret=${KEYCLOAK_CLIENT_SECRET}\nkeycloak.ssl-required=external\nkeycloak.public-client=false\n```\n\n\n## Usage with Spring MockMvc\nHere you can find an example of how to use the `@WithMockKeycloakUser` in a SpringBoot integration test.\nPlease note that in order for Spring to beign able to use the annotation, you will need to setup the mockMvc as shown in the\n`setup()` method.\n\nFor more details on how to leverage Spring Boot Test, please refer to the [Spring documentation](https://docs.spring.io/spring-security/site/docs/current/reference/html/test.html)\n\n```java\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.test.context.SpringBootTest;\nimport org.springframework.test.web.servlet.setup.MockMvcBuilders;\nimport org.springframework.web.context.WebApplicationContext;\nimport org.entando.keycloak.testutils.WithMockKeycloakUser;\n\nimport static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;\n\n@RunWith(SpringRunner.class)\n@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = AvatarPluginApp.class)\npublic class MyCustomTests {\n\n\n    @Autowired\n    private WebApplicationContext applicationContext;\n\n    private MockMvc myMockMvc;\n\n    @Before\n    public void setup() {\n        myMockMvc = MockMvcBuilders\n            .webAppContextSetup(applicationContext)\n            .apply(springSecurity())\n            .build();\n    }\n\n    @Test\n    @WithMockKeycloakUser(username=\"keycloak-user\", roles={\"get-component\",\"post-component\"}, resource=\"entando-plugin-a\")\n    public void mySpecialTest() {\n        // your test code here\n    }\n\n```\n\n**Note**: If no resource is provided in the `resource` field of the `@WithMockKeycloakUser`, by default the resource is set to the `keycloak.resource` defined in the configuration file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentando%2Fkeycloak-connector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fentando%2Fkeycloak-connector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentando%2Fkeycloak-connector/lists"}