Documentation ¶
Overview ¶
Package github provides auth.Authentication and auth.Authorizer implementations backed by GitHub users, orgs and teams.
Index ¶
- Constants
- Variables
- type Authenticator
- type Authorization
- type Client
- func (c *Client) CreateAuthorization(opts CreateAuthorizationOptions) (*Authorization, error)
- func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) GetUser(token string) (*User, error)
- func (c *Client) IsOrganizationMember(organization, token string) (bool, error)
- func (c *Client) IsTeamMember(teamID, token string) (bool, error)
- func (c *Client) NewRequest(method, path string, v interface{}) (*http.Request, error)
- type CreateAuthorizationOptions
- type OrganizationAuthorizer
- type TeamAuthorizer
- type TeamMembership
- type User
Constants ¶
const ( // HeaderTwoFactor is the HTTP header that github users for two factor // authentication. // // In a request, the value of this header should be the two factor auth // code. In a response, the presence of this header indicates that two // factor authentication is required for the user. See // http://goo.gl/h7al6K for more information. HeaderTwoFactor = "X-GitHub-OTP" )
Variables ¶
var (
// DefaultURL is the default location for the GitHub API.
DefaultURL = "https://api.github.com"
)
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authorizer is an implementation of the auth.Authenticator interface backed by GitHub's Non-Web Application Flow, which can be found at http://goo.gl/onpQKM.
func NewAuthenticator ¶
func NewAuthenticator(c *Client) *Authenticator
NewAuthenticator returns a new Authenticator instance that uses the given Client to make calls to GitHub.
func (*Authenticator) Authenticate ¶
func (a *Authenticator) Authenticate(username, password, otp string) (*empire.User, error)
type Authorization ¶
type Authorization struct {
Token string `json:"token"`
}
Authorization represents a GitHub Authorization. See http://goo.gl/bs9I3o for more information.
type Client ¶
type Client struct { // URL for the GitHub API. This can be changed if you're using GitHub // Enterprise. The zero value is DefaultURL. URL string // OAuth configuration. *oauth2.Config // contains filtered or unexported fields }
Client is a github client implementation for creating authorizations, and checking organization membership.
func (*Client) CreateAuthorization ¶
func (c *Client) CreateAuthorization(opts CreateAuthorizationOptions) (*Authorization, error)
CreateAuthorization creates a new GitHub authorization (or returns the existing authorization if present) for the GitHub OAuth application. See http://goo.gl/bs9I3o.
func (*Client) GetUser ¶
GetUser makes an authenticated request to /user and returns the GitHub User.
func (*Client) IsOrganizationMember ¶ added in v0.10.1
IsOrganizationMember returns true of the authenticated user is a member of the organization.
func (*Client) IsTeamMember ¶ added in v0.10.1
IsTeamMember returns true if the given user is a member of the team.
type CreateAuthorizationOptions ¶
CreateAuthorizationOptions is a set of options used when creating a GitHub authorization.
type OrganizationAuthorizer ¶
type OrganizationAuthorizer struct { Organization string // contains filtered or unexported fields }
OrganizationAuthorizer is an implementation of the auth.Authorizer interface that checks that the user is a member of the given GitHub organization.
func NewOrganizationAuthorizer ¶
func NewOrganizationAuthorizer(c *Client) *OrganizationAuthorizer
NewOrganizationAuthorizer returns a new OrganizationAuthorizer instance.
type TeamAuthorizer ¶ added in v0.10.1
type TeamAuthorizer struct { TeamID string // contains filtered or unexported fields }
TeamAuthorizer is an implementation of the auth.Authorizer interface that checks that the user is a member of the given GitHub team.
func NewTeamAuthorizer ¶ added in v0.10.1
func NewTeamAuthorizer(c *Client) *TeamAuthorizer
type TeamMembership ¶ added in v0.10.1
type TeamMembership struct {
State string `json:"state"`
}