{"id":15046670,"url":"https://github.com/auth0/auth0-java-mvc-common","last_synced_at":"2025-04-05T07:08:20.073Z","repository":{"id":42042581,"uuid":"65226093","full_name":"auth0/auth0-java-mvc-common","owner":"auth0","description":"Contains common helper classes and api client logic that are used across our Java MVC libraries","archived":false,"fork":false,"pushed_at":"2025-03-21T03:52:35.000Z","size":564,"stargazers_count":43,"open_issues_count":10,"forks_count":39,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-29T06:08:28.578Z","etag":null,"topics":["dx-sdk","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-08T17:48:45.000Z","updated_at":"2025-01-30T09:56:18.000Z","dependencies_parsed_at":"2023-12-19T15:12:12.154Z","dependency_job_id":"b046d0d6-7d39-44f9-b15e-8910c6b86def","html_url":"https://github.com/auth0/auth0-java-mvc-common","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fauth0-java-mvc-common","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fauth0-java-mvc-common/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fauth0-java-mvc-common/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fauth0-java-mvc-common/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0","download_url":"https://codeload.github.com/auth0/auth0-java-mvc-common/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299833,"owners_count":20916190,"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":["dx-sdk","hacktoberfest"],"created_at":"2024-09-24T20:53:21.939Z","updated_at":"2025-04-05T07:08:20.051Z","avatar_url":"https://github.com/auth0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Auth0 SDK to add authentication to your Java Servlet applications.](https://cdn.auth0.com/website/sdks/banners/auth0-java-mvc-common-banner.png)\n\n![Build Status](https://img.shields.io/github/checks-status/auth0/auth0-java-mvc-common/master)\n[![Coverage Status](https://img.shields.io/codecov/c/github/auth0/auth0-java-mvc-common.svg?style=flat-square)](https://codecov.io/github/auth0/auth0-java-mvc-common)\n[![License](http://img.shields.io/:license-mit-blue.svg?style=flat)](https://doge.mit-license.org/)\n[![Maven Central](https://img.shields.io/maven-central/v/com.auth0/mvc-auth-commons.svg?style=flat-square)](https://mvnrepository.com/artifact/com.auth0/mvc-auth-commons)\n[![javadoc](https://javadoc.io/badge2/com.auth0/auth0-java-mvc-common/javadoc.svg)](https://javadoc.io/doc/com.auth0/mvc-auth-commons)\n\n\u003e **Note**\n\u003e As part of our ongoing commitment to best security practices, we have rotated the signing keys used to sign previous releases of this SDK. As a result, new patch builds have been released using the new signing key. Please upgrade at your earliest convenience.\n\u003e \n\u003e While this change won't affect most developers, if you have implemented a dependency signature validation step in your build process, you may notice a warning that past releases can't be verified. This is expected, and a result of the key rotation process. Updating to the latest version will resolve this for you.\n\n:books: [Documentation](#documentation) - :rocket: [Getting Started](#getting-started) - :computer: [API Reference](#api-reference) :speech_balloon: [Feedback](#feedback)\n\n## Documentation\n\n- [Quickstart](https://auth0.com/docs/quickstart/webapp/java) - our interactive guide for quickly adding login, logout and user information to a Java Servlet application using Auth0.\n- [Sample App](https://github.com/auth0-samples/auth0-servlet-sample/tree/master/01-Login) - a sample Java Servlet application integrated with Auth0.\n- [Examples](./EXAMPLES.md) - code samples for common scenarios.\n- [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.\n\n## Getting Started\n\n### Requirements\n\nJava 8 or above and `javax.servlet` version 3.\n\n\u003e If you are using Spring, we recommend leveraging Spring's OIDC and OAuth2 support, as demonstrated by the [Spring Boot Quickstart](https://auth0.com/docs/quickstart/webapp/java-spring-boot).\n\n### Installation\n\nAdd the dependency via Maven:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.auth0\u003c/groupId\u003e\n  \u003cartifactId\u003emvc-auth-commons\u003c/artifactId\u003e\n  \u003cversion\u003e1.11.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nor Gradle:\n\n```gradle\nimplementation 'com.auth0:mvc-auth-commons:1.11.0'\n```\n\n### Configure Auth0\n\nCreate a **Regular Web Application** in the [Auth0 Dashboard](https://manage.auth0.com/#/applications). Verify that the \"Token Endpoint Authentication Method\" is set to `POST`.\n\nNext, configure the callback and logout URLs for your application under the \"Application URIs\" section of the \"Settings\" page:\n\n- **Allowed Callback URLs**: The URL of your application where Auth0 will redirect to during authentication, e.g., `http://localhost:3000/callback`.\n- **Allowed Logout URLs**: The URL of your application where Auth0 will redirect to after user logout, e.g., `http://localhost:3000/login`.\n\nNote the **Domain**, **Client ID**, and **Client Secret**. These values will be used later.\n\n### Add login to your application\n\nCreate a new `AuthenticationController` using your Auth0 domain, and Auth0 application client ID and secret.\nConfigure the builder with a `JwkProvider` for your Auth0 domain.\n\n```java\npublic class AuthenticationControllerProvider {\n    private String domain = \"YOUR-AUTH0-DOMAIN\";\n    private String clientId = \"YOUR-CLIENT-ID\";\n    private String clientSecret = \"YOUR-CLIENT-SECRET\";\n    \n    private AuthenticationController authenticationController;\n    \n    static {\n        JwkProvider jwkProvider = new JwkProviderBuilder(\"YOUR-AUTH0-DOMAIN\").build();\n        authenticationController = AuthenticationController.newBuilder(domain, clientId, clientSecret)\n                .withJwkProvider(jwkProvider)\n                .build();\n    }\n    \n    public getInstance() {\n        return authenticationController;\n    }\n}\n```\n\n\u003e Note: The `AuthenticationController.Builder` is not to be reused, and an `IllegalStateException` will be thrown if `build()` is called more than once.\n\nRedirect users to the Auth0 login page using the `AuthenticationController`:\n\n```java\n@WebServlet(urlPatterns = {\"/login\"})\npublic class LoginServlet extends HttpServlet {\n\n    @Override\n    protected void doGet(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {\n        // Where your application will handle the authoriztion callback\n        String redirectUrl = \"http://localhost:3000/callback\";\n\n        String authorizeUrl = AuthenticationControllerProvider\n                .getInstance()\n                .buildAuthorizeUrl(req, res, redirectUrl)\n                .build();\n        res.sendRedirect(authorizeUrl);\n    }\n}\n```\n\nFinally, complete the authentication and obtain the tokens by calling `handle()` on the `AuthenticationController`.\n\n```java\n@WebServlet(urlPatterns = {\"/callback\"})\npublic class CallbackServlet extends HttpServlet {\n    \n    @Override\n    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {\n        try {\n            // authentication complete; the tokens can be stored as needed\n            Tokens tokens = AuthenticationControllerProvider\n                    .getInstance()\n                    .handle(req, res);\n            res.sendRedirect(\"URL-AFTER-AUTHENTICATED\");\n        } catch (IdentityVerificationException e) {\n            // handle authentication error\n        }\n    }\n}\n```\n\nThat's it! You have authenticated the user using Auth0.\n\n## API Reference\n\n- [JavaDocs](https://javadoc.io/doc/com.auth0/mvc-auth-commons)\n\n## Feedback\n\n### Contributing\n\nWe appreciate feedback and contribution to this repo! Before you get started, please see the following:\n\n- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)\n- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)\n\n### Raise an issue\nTo provide feedback or report a bug, [please raise an issue on our issue tracker](https://github.com/auth0/auth0-java-mvc-common/issues).\n\n### Vulnerability Reporting\nPlease do not report security vulnerabilities on the public Github issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\"   width=\"150\"\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png\" width=\"150\"\u003e\n    \u003cimg alt=\"Auth0 Logo\" src=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003eAuth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout \u003ca href=\"https://auth0.com/why-auth0\"\u003eWhy Auth0?\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\nThis project is licensed under the MIT license. See the \u003ca href=\"./LICENSE\"\u003e LICENSE\u003c/a\u003e file for more info.\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fauth0-java-mvc-common","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0%2Fauth0-java-mvc-common","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fauth0-java-mvc-common/lists"}