github-oauth-servlet is a drop-in Servlet that adds GitHub organization-based authentication to your J2EE project.
Set the following configuration, either as envrionment variables or as Java system properties:
GH_CLIENT_ID: The client ID you received from GitHub when you registered
GH_CLIENT_SECRET: The client secret you received from GitHub when you registered.
GH_OAUTH_URL: For production, use https://github.com/login/oauth. For development and testing, consider using a local mock server instead.
GH_API_URL: For production, use https://api.github.com. For development and testing, consider using a local mock server instead.
GH_ORG: The GitHub organization that users must be a member of to authenticate.
Drop the Servlet into your web.xml:
<servlet> <servlet-name>github oauth servlet</servlet-name> <servlet-class>com.udacity.github.oauth.GitHubOauthServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>github oauth servlet</servlet-name> <url-pattern>/oauth/github/*</url-pattern> </servlet-mapping>
To authenticate a user, redirect them to
$continue is a URI-encoded URL to redirect to after successful
Upon successful authentication, the
auth-key cookie will be set, with
which the user can be looked up via