github

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package github implements authentication provider implementation for authentication source GitHub.

Using GitHub as the authentication provider, this application can leverage both individual style accounts and organisational accounts with added support for organisation wide and team based authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(username string, configuration interface{}) (users string, err error)

Call is a package entrypoint for underlying application. username defines the system user used for access. configuration defines the generic interface to pass the provider configuration from underlying application.

func NewHttpRequest

func NewHttpRequest(method string, url string, body io.Reader) *http.Request

NewHttpRequest creates a http request for the given parameters error out on failure

Types

type AccessToken

type AccessToken struct {
	Token       string      `json:"token"`
	Expire      string      `json:"expires_at"`
	Permissions interface{} `json:"permissions"`
}

AccessToken defines the structure of Github response to access token request.

func (*AccessToken) AccessToken

func (t *AccessToken) AccessToken(c Configuration)

AccessToken requests application access token from Github for authentication of the other calls

func (AccessToken) OrgMembers

func (t AccessToken) OrgMembers(c Configuration, username string) *[]User

OrgMembers gets a list of members of the organisation according to the role

func (*AccessToken) TeamsMembers

func (t *AccessToken) TeamsMembers(c Configuration, username string) *[]User

TeamsMembers gets a list of members of the given team according to the role

type Claims

type Claims struct {
	jwt.StandardClaims
	Iss int `json:"iss"`
}

Claims defines the override structure for the jwt.StandardClaims

func (*Claims) CreateToken

func (c *Claims) CreateToken() (string, error)

CreateToken creates a signed JWT token that is used to request the access token

func (*Claims) Sign

func (c *Claims) Sign() (*rsa.PrivateKey, error)

Sign signs the given token with specified private key

type Configuration

type Configuration struct {
	InstallationId int    `json:"installation_id"`
	AdminRole      string `json:"admin_role"`
	ApiUrl         string `json:"api_url"`
	DefaultRole    string `json:"default_role"`
	Org            string `json:"org"`
	TeamName       string `json:"team_name"`
	MediaType      string `json:"media_type"`
	Token          string `json:"-"`
}

Configuration defines the structure for the configuration needed to complete a query to Github API.

func (*Configuration) HttpCall

func (c *Configuration) HttpCall(request *http.Request, response interface{}, statusCode int) error

HttpCall makes Http request for the given request and maps the response to given response pinter.

request defines the pointer for http.Request response defines the generic interface pointer to map the response statusCode defines the http status code to for successful response

type Key

type Key struct {
	Id  int    `json:"id"`
	Key string `json:"key"`
}

Key defines the structure for the response of Github when requesting user's keys

type KeyChain

type KeyChain struct {
	Username string   `json:"username"`
	Keys     []string `json:"keys"`
}

type Team

type Team struct {
	Name            string `json:"name"`
	Id              int    `json:"id"`
	NodeId          string `json:"node_id"`
	Slug            string `json:"slug"`
	Description     string `json:"description"`
	Privacy         string `json:"privacy"`
	Url             string `json:"url"`
	MembersUrl      string `json:"members_url"`
	RepositoriesUrl string `json:"repositories_url"`
	Permission      string `json:"permission"`
}

Team defines the structure for the response of Github when requesting teams in an organisation.

func (*Team) GetTeam

func (t *Team) GetTeam(c Configuration) error

GetTeam gets list of teams in the given organisation

type User

type User struct {
	Login  string `json:"login"`
	Id     int    `json:"id"`
	NodeId string `json:"node_id"`
	//AvatarUrl         string `json:"avatar_url"`
	//GravatarId        string `json:"gravatar_id"`
	Url               string `json:"url"`
	HtmlUrl           string `json:"html_url"`
	FollowersUrl      string `json:"followers_url"`
	FollowingUrl      string `json:"following_url"`
	GistsUrl          string `json:"gists_url"`
	StarredUrl        string `json:"starred_url"`
	SubscriptionsUrl  string `json:"subscriptions_url"`
	OrganizationsUrl  string `json:"organizations_url"`
	ReposUrl          string `json:"repos_url"`
	EventsUrl         string `json:"events_url"`
	ReceivedEventsUrl string `json:"received_events_url"`
	Type              string `json:"type"`
	SiteAdmin         bool   `json:"site_admin"`
}

User defines the structure for the response of Github when requesting user.

func (*User) UserKeys

func (u *User) UserKeys(c Configuration) *[]Key

UserKeys gets keys on the user accounts given to the method

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL