web

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2019 License: AGPL-3.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserID

func GetUserID(ctx context.Context) (int, error)

GetUserID gets the user ID set by the JWT middleware in the Context

func GetUserLogin added in v0.8.0

func GetUserLogin(ctx context.Context) (string, error)

GetUserLogin gets the user login set by the JWT middleware in the Context

func RequestLogger added in v0.8.0

func RequestLogger(next http.Handler) http.Handler

RequestLogger middleware logs all incoming requests and adds log fields to the request context

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

Auth is http service to authorize users, it uses oAuth and JWT underneath

func NewAuth

func NewAuth(clientID, clientSecret string, signingKey string) *Auth

NewAuth create new Auth service

func (*Auth) Callback

func (a *Auth) Callback(w http.ResponseWriter, r *http.Request)

Callback makes exchange with oauth provider and redirects to index page with JWT token

func (*Auth) Login

func (a *Auth) Login(w http.ResponseWriter, r *http.Request)

Login handler redirects user to oauth provider

func (*Auth) Me added in v0.8.0

func (a *Auth) Me(w http.ResponseWriter, r *http.Request)

Me endpoint make request to provider and returns user details

func (*Auth) Middleware

func (a *Auth) Middleware(next http.Handler) http.Handler

Middleware return http.Handler which validates token and set user id in context

type GitHub added in v0.8.0

type GitHub struct {
	AppID          int
	PrivateKey     string
	OrganizationOp store.OrganizationOperator
}

GitHub is an HTTP service to call GitHub endpoints

func (*GitHub) Org added in v0.8.0

func (g *GitHub) Org(w http.ResponseWriter, r *http.Request)

Org writes in the response the individual organization requested by the URL parameter "orgName", only if the user is an admin

func (*GitHub) Orgs added in v0.8.0

func (g *GitHub) Orgs(w http.ResponseWriter, r *http.Request)

Orgs writes in the response the list of organizations where the logged-in user is an admin

func (*GitHub) UpdateOrg added in v0.8.0

func (g *GitHub) UpdateOrg(w http.ResponseWriter, r *http.Request)

UpdateOrg is a hander that updates the organization settings, and returns the updated organization information with the same response as Org

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

func NewHTTPServer

func NewHTTPServer(auth *Auth, gh *GitHub, static *Static) *HTTPServer

func (*HTTPServer) ServeHTTP

func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Static

type Static struct{}

Static without the 'with_static' tag contains a placeholder handler that returns 'not implemented'

func NewStatic

func NewStatic(dir, serverURL string, footerHTML string) *Static

NewStatic creates new Static

func (*Static) ServeHTTP

func (s *Static) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves any static file from static directory or fallbacks on index.hml

type User

type User struct {
	ID        int    `json:"id"`
	Login     string `json:"login"`
	Username  string `json:"name"`
	AvatarURL string `json:"avatar_url"`
}

User represents the user response returned by provider

Jump to

Keyboard shortcuts

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