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 registeredGH_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 /oauth/github[/$continue]
,
where $continue
is a URI-encoded URL to redirect to after successful
authentication.
Upon successful authentication, the auth-key
cookie will be set, with
which the user can be looked up via GitHubOauthServlet#get
.
This repository is deprecated; therefore, we are going to archive it. However, learners will be able to fork it to their personal Github account but cannot submit PRs to this repository. If you have any issues or suggestions to make, feel free to:
- Utilize the https://knowledge.udacity.com/ forum to seek help on content-specific issues.
- Submit a support ticket along with the link to your forked repository if (learners are) blocked for other reasons. Here are the links for the retail consumers and enterprise learners.