{"id":17685283,"url":"https://github.com/hakky54/gatekeeper","last_synced_at":"2025-05-13T00:02:06.834Z","repository":{"id":53506869,"uuid":"339885220","full_name":"Hakky54/gatekeeper","owner":"Hakky54","description":"🔐 A lightweight java library which guards your publicly accessible internal implementations.","archived":false,"fork":false,"pushed_at":"2023-04-08T11:23:39.000Z","size":187,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-13T00:01:57.149Z","etag":null,"topics":["java","security"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hakky54.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":"2021-02-17T23:42:44.000Z","updated_at":"2023-03-19T08:46:57.000Z","dependencies_parsed_at":"2024-10-24T13:04:30.646Z","dependency_job_id":"fdcf9c04-7708-4000-98a8-cdb1ba3b1824","html_url":"https://github.com/Hakky54/gatekeeper","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hakky54%2Fgatekeeper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hakky54%2Fgatekeeper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hakky54%2Fgatekeeper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hakky54%2Fgatekeeper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hakky54","download_url":"https://codeload.github.com/Hakky54/gatekeeper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843195,"owners_count":21972872,"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":["java","security"],"created_at":"2024-10-24T10:27:14.661Z","updated_at":"2025-05-13T00:02:06.595Z","avatar_url":"https://github.com/Hakky54.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/Hakky54/gatekeeper/workflows/Build/badge.svg)](https://github.com/Hakky54/gatekeeper/actions)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=io.github.hakky54%3Agatekeeper\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=io.github.hakky54%3Agatekeeper)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=io.github.hakky54%3Agatekeeper\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=io.github.hakky54%3Agatekeeper)\n[![Apache2 license](https://img.shields.io/badge/license-Aache2.0-blue.svg)](https://github.com/Hakky54/gatekeeper/blob/master/LICENSE)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.hakky54/gatekeeper/badge.svg)](https://mvnrepository.com/artifact/io.github.hakky54/gatekeeper)\n[![javadoc](https://javadoc.io/badge2/io.github.hakky54/gatekeeper/javadoc.svg)](https://javadoc.io/doc/io.github.hakky54/gatekeeper)\n\n[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-white.svg)](https://sonarcloud.io/dashboard?id=io.github.hakky54%3Agatekeeper)\n\n# Gatekeeper 🔐 [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Easily%20protect%20your%20publicly%20accessible%20internal%20implementations%20with%20Gatekeeper\u0026url=https://github.com/Hakky54/gatekeeper\u0026via=hakky541\u0026hashtags=security,developer,java,gatekeeper)\n![braces-clipart-punctuation-6-original](img/gatekeepers.jpg)\n\n## Introduction\nGatekeeper is a library which guards your publicly accessible internal implementations.\n\n### History\nLibrary maintainers have a hard time to keep internal implementations internal and prevent it to be accessible by library users.\nThe library maintainer cannot easily change internal implementations as it may lead into breaking changes for the library users.\nA straight forward method for library maintainers would be making classes package protected and accessible through public api's so-called Service classes.\nEncapsulation internal api's and exposing it through service classes is the preferred way but cannot be achieved in some use cases. Restrictions by Java Modules will not work if the end-user is not using java modules.\nGatekeeper will ensure that these internal implementations remain internal by validating the caller. You as a library developer can choose who is allowed to call your classes.\n\n### Minimum requirements:\n- Java 8\n\n# Install library with:\n### Install with [Maven](https://mvnrepository.com/artifact/io.github.hakky54/gatekeeper)\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.hakky54\u003c/groupId\u003e\n    \u003cartifactId\u003egatekeeper\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n### Install with Gradle\n```groovy\nimplementation 'io.github.hakky54:gatekeeper:1.0.2'\n```\n### Install with Scala SBT\n```\nlibraryDependencies += \"io.github.hakky54\" % \"gatekeeper\" % \"1.0.2\"\n```\n### Install with Apache Ivy\n```xml\n\u003cdependency org=\"io.github.hakky54\" name=\"gatekeeper\" rev=\"1.0.2\" /\u003e\n```\n\n## Usage\n**Internal API - Protected by Gatekeeper**\n```java\nimport nl.altindag.gatekeeper.Gatekeeper;\n\npublic class FooInternal {\n\n    public String hello() {\n        Gatekeeper.ensureCallerIsAnyOf(FooService.class);\n        return \"Hello\";\n    }\n}\n```\n**Public API - Exposed**\n```java\npublic class FooService {\n    \n    private final FooInternal fooInternal = new FooInternal();\n\n    public String hello() {\n        return fooInternal.hello();\n    }\n}\n```\n```java\npublic class App {\n\n    public static void main(String[] args) {\n        FooService fooService = new FooService();\n        String hello = fooService.hello();\n        System.out.println(hello); // ---\u003e prints Hello\n        \n        FooInternal fooInternal = new FooInternal();\n        fooInternal.hello(); // ---\u003e throws a (runtime) GatekeeperException with an explaining message\n    }\n    \n}\n```\n## Bulletproof?\nThis library provides a protection by checking the caller at runtime, but it is sadly not 100% bulletproof. It just makes it a bit tougher for the end-user to use the protected classes. \nUnfortunately this protection can be bypassed with two methods:\n1. Calling the protected class with a class that has the same class name and package to specified allowable class.\n2. Overriding the jar with a modified version which doesn't validate at all.\n\nYou should know about these use cases before considering using this library. It cannot give 100% protection if the end-user is using one of the two methods to bypass it. \nIf you are ok with that, go ahead or else I would recommend to use java's Sealed classes which are available from Java 15 onwards.\n\n## Contributing\n\nThere are plenty of ways to contribute to this project:\n\n* Give it a star\n* Share it with a [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Easily%20protect%20your%20publicly%20accessible%20internal%20implementations%20with%20Gatekeeper\u0026url=https://github.com/Hakky54/gatekeeper\u0026via=hakky541\u0026hashtags=security,developer,java,gatekeeper)\n* Submit a PR\n\n## Resources\n- [Gatekeeper image](https://innovationcloud.com/blog/the-gatekeepers-heavy-burden-of-decision-making-explained.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakky54%2Fgatekeeper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhakky54%2Fgatekeeper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakky54%2Fgatekeeper/lists"}