handler
v1.1.1
Documentation
pkg.go.dev ↗Types
App
type App struct {
web.Handler
// contains filtered or unexported fields
}
App handles serving responses to managing an OAuth app that a user has created for OAuth access to the API.
NewApp
func NewApp(h web.Handler, crypto *crypto.AESGCM) App
App.Create
func (h App) Create(w http.ResponseWriter, r *http.Request)
Create serves the HTML response for creating a new OAuth app.
App.Index
func (h App) Index(w http.ResponseWriter, r *http.Request)
Index serves the HTML response detailing the list of OAuth apps for the current user.
App.Show
func (h App) Show(w http.ResponseWriter, r *http.Request)
Show serves the individual HTML response for viewing an individual OAuth app.
App.Store
func (h App) Store(w http.ResponseWriter, r *http.Request)
Store validates the form submitted in the given request for creating an OAuth app. If validation fails then the user is redirected back to the request referer, otherwise they are redirect back to the OAuth app index.
App.Update
func (h App) Update(w http.ResponseWriter, r *http.Request)
Update validates the form submitted in the given request for updating an OAuth app. If validation fails then the user is redirect back to the request's referer, otherwise they are redirected back to the updated OAuth app. If the base of the requested URL path is "/revoke" then this will revoke all of the access tokens for this app. If the base of the path is "/reset" then it will generate a new client secret.
Connection
type Connection struct {
web.Handler
// contains filtered or unexported fields
}
Connection handles serving the responses to managing the OAuth apps that have connected to a user's account.
NewConnection
func NewConnection(h web.Handler) Connection
Connection.Destroy
func (h Connection) Destroy(w http.ResponseWriter, r *http.Request)
Destroy will delete the connection from the user's account. This will delete the underlying access token that was generated for the user from the database.
Connection.Index
func (h Connection) Index(w http.ResponseWriter, r *http.Request)
Index serves the HTML response detailing the list of connected apps.
Connection.Show
func (h Connection) Show(w http.ResponseWriter, r *http.Request)
Show serves the HTML response detailing an individual connected app.
Oauth2
type Oauth2 struct {
web.Handler
// contains filtered or unexported fields
}
Oauth2 is the handler that handles the OAuth token webflow.
New
func New(h web.Handler, block *crypto.AESGCM) Oauth2
Oauth2.Auth
func (h Oauth2) Auth(w http.ResponseWriter, r *http.Request)
Auth will either serve up the OAuth login page on a GET request, or process the submitted form on a POST request. If the user has already granted access to the OAuth app then nothing happens, and they are simply redirected back to the app's redirect URL. If any scopes changed, then the original access token generated for the user (if any) is updated with the new scopes.
Oauth2.Revoke
func (h Oauth2) Revoke(w http.ResponseWriter, r *http.Request)
Revoke revokes the OAuth token in the given request header.
Oauth2.Token
func (h Oauth2) Token(w http.ResponseWriter, r *http.Request)
Token will serve the JSON encoded access token for the user that granted access to an OAuth app. This uses the OAuth code submitted in the request as a means of authentication. If the submitted code has not expired then the token is created, and returned in the response. The tokens generated do not expire.
Token
type Token struct {
web.Handler
// contains filtered or unexported fields
}
Token handles serving responses for managing personal access tokens that a user creates to access the API.
NewToken
func NewToken(h web.Handler) Token
Token.Create
func (h Token) Create(w http.ResponseWriter, r *http.Request)
Create serves the HTML response for creating a new personal access token.
Token.Destroy
func (h Token) Destroy(w http.ResponseWriter, r *http.Request)
Destroy removes the token in the request from the database.
Token.Edit
func (h Token) Edit(w http.ResponseWriter, r *http.Request)
Edit serves the HTML response for editing a personal access token.
Token.Index
func (h Token) Index(w http.ResponseWriter, r *http.Request)
Index serves the HTML response detailing the list of personal access tokens created for the current user.
Token.Store
func (h Token) Store(w http.ResponseWriter, r *http.Request)
Store validates the form submitted in the given request for creating a personal access token. If validation fails then the user is redirected back to the request referer, otherwise they are redirect back to the token index. If no specific scopes are specified in the form submission, then all scopes are added to the created token.
Token.Update
func (h Token) Update(w http.ResponseWriter, r *http.Request)
Update validates the form submitted in the given request for updating token. If validation fails then the user is redirect back to the request's referer, otherwise they are redirected back to the token index. If the base path of the request URL is "/regenerate", then the token is simply regenerated.