Documentation ¶
Index ¶
- Variables
- func BuildPrivateKey(content []byte) (*rsa.PrivateKey, error)
- func Query(query string, args ...interface{}) (*sql.Rows, error)
- func QueryRow(query string, args ...interface{}) (*sql.Row, error)
- func RepositoriesCount() (int64, error)
- type Cloner
- type Database
- type GitHub
- type Message
- type Pusher
- type Repository
- type Rsa
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var GitHubLoginRequired martini.Handler = func() martini.Handler { failedLogin := func(req *http.Request, writer http.ResponseWriter, s sessions.Session) { s.Delete("oauth2_token") s.Delete("isAllowed") next := url.QueryEscape(req.URL.RequestURI()) http.Redirect(writer, req, oauth2.PathLogin+"?next="+next, 302) } return func(s sessions.Session, token oauth2.Tokens, c martini.Context, writer http.ResponseWriter, req *http.Request, rend render.Render) { isAllowed := s.Get("isAllowed") if token == nil || token.IsExpired() { failedLogin(req, writer, s) } else if isAllowed != true { hub := BuildGitHub() client := hub.GetClient(token.Access()) user, _, _ := client.Users.Get("") if user == nil { failedLogin(req, writer, s) } else if int64(*user.ID) == hub.OauthAllowedId { s.Set("isAllowed", true) } else { orgs, _, _ := client.Organizations.List("", &github.ListOptions{}) for _, org := range orgs { if int64(*org.ID) == hub.OauthAllowedId { return } } rend.HTML(401, "not_allowed", nil) } } } }()
Functions ¶
func BuildPrivateKey ¶
func BuildPrivateKey(content []byte) (*rsa.PrivateKey, error)
func RepositoriesCount ¶
Types ¶
type Cloner ¶
type Cloner struct { Repository *Repository Path string }
func NewCloner ¶
func NewCloner(repository *Repository, path string) *Cloner
type Database ¶
func GetDbConnection ¶
type GitHub ¶
type GitHub struct { OauthKey string OauthSecret string OauthRedirectUri string OauthAllowedId int64 SessionToken []byte }
func BuildGitHub ¶
func BuildGitHub() *GitHub
type Message ¶
type Message struct { Id int `form:"id"` Sha string `form:"sha"` Repository *Repository }
type Repository ¶
func AllRepositories ¶
func AllRepositories() ([]Repository, error)
func BuildRepository ¶
func BuildRepository(id int64, origin string, destination string, rsa_key []byte) *Repository
func FindRepository ¶
func FindRepository(id int64) (*Repository, error)
func (*Repository) IsNew ¶
func (r *Repository) IsNew() bool
func (*Repository) LocalPath ¶
func (r *Repository) LocalPath() string
func (*Repository) Name ¶
func (r *Repository) Name() string
func (*Repository) Save ¶
func (r *Repository) Save() error
func (*Repository) Token ¶
func (r *Repository) Token() string
type Rsa ¶
type Rsa struct { Repository *Repository Private *rsa.PrivateKey }
func BuildRsa ¶
func BuildRsa(repository *Repository, ssh_key []byte) *Rsa
func (*Rsa) PrivateKey ¶
Click to show internal directories.
Click to hide internal directories.