Documentation ¶
Overview ¶
Package handlers contains the HTTP handlers for Go-NEB.
This includes detail on the API paths and top-level JSON keys. For specific service JSON, see the service you're interested in.
See also ¶
Package "api" for the format of the JSON request bodies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigureAuthRealm ¶
ConfigureAuthRealm represents an HTTP handler capable of processing /admin/configureAuthRealm requests.
func (*ConfigureAuthRealm) OnIncomingRequest ¶
func (h *ConfigureAuthRealm) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest handles POST requests to /admin/configureAuthRealm. The JSON object provided is of type "api.ConfigureAuthRealmRequest".
Request:
POST /admin/configureAuthRealm { "ID": "my-realm-id", "Type": "github", "Config": { // Realm-specific configuration information } }
Response:
HTTP/1.1 200 OK { "ID": "my-realm-id", "Type": "github", "OldConfig": { // Old auth realm config information }, "NewConfig": { // New auth realm config information }, }
type ConfigureClient ¶
ConfigureClient represents an HTTP handler capable of processing /admin/configureClient requests.
func (*ConfigureClient) OnIncomingRequest ¶
func (s *ConfigureClient) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest handles POST requests to /admin/configureClient. The JSON object provided is of type "api.ClientConfig".
If a DisplayName is supplied, this request will set this client's display name if the old ClientConfig DisplayName differs from the new ClientConfig DisplayName.
Request:
POST /admin/configureClient { "UserID": "@my_bot:localhost", "HomeserverURL": "http://localhost:8008", "Sync": true, "DisplayName": "My Bot" }
Response:
HTTP/1.1 200 OK { "OldClient": { // The old api.ClientConfig }, "NewClient": { // The new api.ClientConfig } }
type ConfigureService ¶
type ConfigureService struct {
// contains filtered or unexported fields
}
ConfigureService represents an HTTP handler which can process /admin/configureService requests.
func NewConfigureService ¶
func NewConfigureService(db *database.ServiceDB, clients *clients.Clients) *ConfigureService
NewConfigureService creates a new ConfigureService handler
func (*ConfigureService) OnIncomingRequest ¶
func (s *ConfigureService) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest handles POST requests to /admin/configureService.
The request body MUST be of type "api.ConfigureServiceRequest".
Request:
POST /admin/configureService { "ID": "my_service_id", "Type": "service-type", "UserID": "@my_bot:localhost", "Config": { // service-specific config information } }
Response:
HTTP/1.1 200 OK { "ID": "my_service_id", "Type": "service-type", "OldConfig": { // old service-specific config information }, "NewConfig": { // new service-specific config information }, }
type GetService ¶
GetService represents an HTTP handler which can process /admin/getService requests.
func (*GetService) OnIncomingRequest ¶
func (h *GetService) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest handles POST requests to /admin/getService.
The request body MUST be a JSON body which has an "ID" key which represents the service ID to get.
Request:
POST /admin/getService { "ID": "my_service_id" }
Response:
HTTP/1.1 200 OK { "ID": "my_service_id", "Type": "github", "Config": { // service-specific config information } }
type GetSession ¶
GetSession represents an HTTP handler capable of processing /admin/getSession requests.
func (*GetSession) OnIncomingRequest ¶
func (h *GetSession) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest handles POST requests to /admin/getSession.
The JSON object provided MUST have a "RealmID" and "UserID" in order to fetch the correct AuthSession. If there is no session for this tuple of realm and user ID, a 200 OK is still returned with "Authenticated" set to false.
Request:
POST /admin/getSession { "RealmID": "my-realm", "UserID": "@my_user:localhost" }
Response:
HTTP/1.1 200 OK { "ID": "session_id", "Authenticated": true, "Info": { // Session-specific config info } }
Response if session not found:
HTTP/1.1 200 OK { "Authenticated": false }
type Heartbeat ¶
type Heartbeat struct{}
Heartbeat implements the heartbeat API
func (*Heartbeat) OnIncomingRequest ¶
func (*Heartbeat) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest returns an empty JSON object which can be used to detect liveness of Go-NEB.
Request:
GET /test
Response:
HTTP/1.1 200 OK {}
type RealmRedirect ¶
RealmRedirect represents an HTTP handler which can process incoming redirects for auth realms.
func (*RealmRedirect) Handle ¶
func (rh *RealmRedirect) Handle(w http.ResponseWriter, req *http.Request)
Handle requests for an auth realm.
The last path segment of the URL MUST be the base64 form of the Realm ID. What response this returns depends on the specific AuthRealm implementation.
type RemoveAuthSession ¶
RemoveAuthSession represents an HTTP handler capable of processing /admin/removeAuthSession requests.
func (*RemoveAuthSession) OnIncomingRequest ¶
func (h *RemoveAuthSession) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest handles POST requests to /admin/removeAuthSession.
The JSON object MUST contain the keys "RealmID" and "UserID" to identify the session to remove.
Request
POST /admin/removeAuthSession { "RealmID": "github-realm", "UserID": "@my_user:localhost" }
Response:
HTTP/1.1 200 OK {}
type RequestAuthSession ¶
RequestAuthSession represents an HTTP handler capable of processing /admin/requestAuthSession requests.
func (*RequestAuthSession) OnIncomingRequest ¶
func (h *RequestAuthSession) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest handles POST requests to /admin/requestAuthSession. The HTTP body MUST be a JSON object representing type "api.RequestAuthSessionRequest".
This will return HTTP 400 if there are missing fields or the Realm ID is unknown. For the format of the response, see the specific AuthRealm that the Realm ID corresponds to.
Request:
POST /admin/requestAuthSession { "RealmID": "github_realm_id", "UserID": "@my_user:localhost", "Config": { // AuthRealm specific config info } }
Response:
HTTP/1.1 200 OK { // AuthRealm-specific information }
type VerifySAS ¶
VerifySAS represents an HTTP handler capable of processing /verifySAS requests.
func (*VerifySAS) OnIncomingRequest ¶
func (s *VerifySAS) OnIncomingRequest(req *http.Request) util.JSONResponse
OnIncomingRequest handles POST requests to /verifySAS. The JSON object provided is of type "api.IncomingDecimalSAS".
The request should contain the three decimal SAS numbers as displayed on the other device that is being verified, as well as that device's user and device ID. It should also contain the user ID that Go-NEB's client is using.
Request:
POST /verifySAS { "UserID": "@my_bot:localhost", // Neb's user ID "OtherUserID": "@user:localhost", // User ID of device we're verifying with "OtherDeviceID": "ABCDEFG", // Device ID of device we're verifying with "SAS": [1111, 2222, 3333] // SAS displayed on device we're verifying with }
Response:
HTTP/1.1 200 OK {}
type Webhook ¶
type Webhook struct {
// contains filtered or unexported fields
}
Webhook represents an HTTP handler capable of accepting webhook requests on behalf of services.
func NewWebhook ¶
NewWebhook returns a new webhook HTTP handler
func (*Webhook) Handle ¶
func (wh *Webhook) Handle(w http.ResponseWriter, req *http.Request)
Handle an incoming webhook HTTP request.
The webhook MUST have a known base64 encoded service ID as the last path segment in order for this request to be passed to the correct service, or else this will return HTTP 400. If the base64 encoded service ID is unknown, this will return HTTP 404. Beyond this, the exact response is determined by the specific Service implementation.