-
Notifications
You must be signed in to change notification settings - Fork 22
Github APIs for authentication
These are the APIs rancher calls for authentication and user/org/team lookup against a Github server.
-
Default Github host: https://github.com and default Github API endpoint: https://api.github.com
-
For private/enterprise Github setups, the API endpoint: "Private Github Hostname" + "/api/v3"
-
All Github APIs are HTTP POST or GET APIs.
-
For Github POST set following headers:
- "Content-Type", "application/x-www-form-urlencoded"
- "Accept", "application/json"
-
For Github GET set following headers:
- "Authorization", "token "+ githubAccessToken
- "Accept", "application/json"
- "user-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36)"
-
Authenticate (clientId, clientSecret): HTTP POST to [Github Server Hostname + "/login/oauth/access_token"] The accessToken received should be used in the "Authorization" header for subsequent API calls.
-
Get User by name: HTTP GET to [Github API endpoint + "/users/<user_name>"]
-
Get Org by name: HTTP GET to [Github API endpoint + "/orgs/<org_name>"]
-
Get Team by Id: HTTP GET to [Github API endpoint + "/teams/<team_id>"]
-
Get User Details HTTP GET to [Github API endpoint + "/user"] with Github Access token in Authorization header, to get current user details. OR HTTP GET to [Github API endpoint + "/user/<user_id>"] to get details of some other user.
-
Get Orgs of a user HTTP GET to [Github API endpoint + "/user/orgs?per_page=1"] with Github Access token in Authorization header
-
Get Teams of a user HTTP GET to [Github API endpoint + "/user/teams?per_page=100"] with Github Access token in Authorization header
For detail implementation, refer: https://github.com/rancher/rancher-auth-service/tree/master/providers/github