Commit 6fb20c24 authored by ale's avatar ale
Browse files

Fix usermetadb client.New invocation

Upstream changed the New parameters
parent 18e58d3b
......@@ -22,11 +22,7 @@ type deviceFilter struct {
var usermetadbTimeout = 3 * time.Second
func newDeviceFilter(config *client.Config) (*deviceFilter, error) {
tlsConfig, err := config.TLSConfig.TLSConfig()
if err != nil {
return nil, err
}
c, err := client.New(config.BackendURL, tlsConfig)
c, err := client.New(config)
if err != nil {
return nil, err
}
......
......@@ -26,7 +26,7 @@ a specific device and an account if one is in possession of the
server-side log database (only partially mitigated by the fact that
the cookie is encrypted).
## API
# API
The server exports an API over HTTP/HTTPS, all requests should be made
using the POST method and an *application/json* Content-Type. The
......@@ -36,26 +36,48 @@ will similarly be JSON-encoded.
The API is split into two conceptually separate sets, the *log* API
and the *analysis* API.
### Log API
## Log API
`/api/add_log` (*AddLogRequest*)
Stores a new log entry for a user in the database. The request must
be a `LogEntry` object. The method returns an empty response. If
the log entry contains device information, the list of devices for
the specified user is updated with that information.
Stores a new log entry for a user in the database. The request must be
a `LogEntry` object. The method returns an empty response. If the log
entry contains device information, the list of devices for the
specified user is updated with that information.
`/api/get_user_logs` (*GetUserLogsRequest*) -> *GetUserLogsResponse*
Returns recent logs for a specific user.
Returns recent logs for a specific user.
`/api/get_user_devices` (*GetUserDevicesRequest*) -> *GetUserDevicesResponse*
Returns the list of known devices for a user
Returns the list of known devices for a user.
## Analysis API
`/api/check_device` (*CheckDeviceRequest*) -> *CheckDeviceResponse*
Returns information about a device, whether we have seen it before,
if the localization information matches the historical trend, etc.
Returns information about a device, whether we have seen it before, if
the localization information matches the historical trend, etc.
# Configuration
The configuration is contained in a YAML-encoded file, normally
`/etc/user-meta-server.yml` (this can be changed using the
*--config* command-line flag).
The known attributes are:
* `db_uri` is the database URI. As currently only the *sqlite3* driver
is supported, this is just the path to the database file.
* `http_server` specifies standard parameters for the HTTP server:
* `tls` contains the server-side TLS configuration:
* `cert` is the path to the server certificate
* `key` is the path to the server's private key
* `ca` is the path to the CA used to validate clients
* `acl` specifies TLS-based access controls, a list of entries
with the following attributes:
* `path` is a regular expression to match the request URL path
* `cn` is a regular expression that must match the CommonName
part of the subject of the client certificate
......@@ -13,30 +13,41 @@ import (
"git.autistici.org/id/usermetadb"
)
// Client for the user-meta-server API.
type Client struct {
*http.Client
backendURL string
}
// Config for a user-meta-server API client.
type Config struct {
BackendURL string `yaml:"backend_url"`
TLSConfig *clientutil.TLSClientConfig `yaml:"tls_config"`
}
func New(backendURL string, tlsConfig *tls.Config) (*Client, error) {
u, err := url.Parse(backendURL)
// New returns a new Client with the given Config.
func New(config *Config) (*Client, error) {
u, err := url.Parse(config.BackendURL)
if err != nil {
return nil, err
}
var tlsConfig *tls.Config
if config.TLSConfig != nil {
tlsConfig, err = config.TLSConfig.TLSConfig()
if err != nil {
return nil, err
}
}
c := &http.Client{
Transport: clientutil.NewTransport([]string{u.Host}, tlsConfig, nil),
Timeout: 10 * time.Second,
}
return &Client{
Client: c,
backendURL: backendURL,
backendURL: config.BackendURL,
}, nil
}
......
......@@ -6,15 +6,15 @@
"checksumSHA1": "raJx5BjBbVQG0ylGSjPpi+JvqjU=",
"origin": "git.autistici.org/id/usermetadb/vendor/git.autistici.org/ai3/go-common",
"path": "git.autistici.org/ai3/go-common",
"revision": "a5c1112b0e170bd76b30208f7b008277be32fc61",
"revisionTime": "2017-12-09T10:54:51Z"
"revision": "870324b771df3ab35be9b881a1c4981260e18b5d",
"revisionTime": "2017-12-09T12:27:05Z"
},
{
"checksumSHA1": "D8Sp0BhEzo+0mvEHnWlAN8ysu8A=",
"origin": "git.autistici.org/id/usermetadb/vendor/git.autistici.org/ai3/go-common/clientutil",
"path": "git.autistici.org/ai3/go-common/clientutil",
"revision": "a5c1112b0e170bd76b30208f7b008277be32fc61",
"revisionTime": "2017-12-09T10:54:51Z"
"revision": "870324b771df3ab35be9b881a1c4981260e18b5d",
"revisionTime": "2017-12-09T12:27:05Z"
},
{
"checksumSHA1": "DzKDWajBfvUFvGrt8ju8icbUmCA=",
......@@ -23,16 +23,16 @@
"revisionTime": "2017-12-09T10:27:16Z"
},
{
"checksumSHA1": "e0sJps+9hsMCRFh/UCoQPBeJHZs=",
"checksumSHA1": "7Kbb9vTjqcQhhxtSGpmp9rk6PUk=",
"path": "git.autistici.org/id/usermetadb",
"revision": "a5c1112b0e170bd76b30208f7b008277be32fc61",
"revisionTime": "2017-12-09T10:54:51Z"
"revision": "870324b771df3ab35be9b881a1c4981260e18b5d",
"revisionTime": "2017-12-09T12:27:05Z"
},
{
"checksumSHA1": "Seinz9LGvHl33fARgteyVE2oyUA=",
"checksumSHA1": "WkbTf01lQyXPIjdrmQLNQSCGauE=",
"path": "git.autistici.org/id/usermetadb/client",
"revision": "a5c1112b0e170bd76b30208f7b008277be32fc61",
"revisionTime": "2017-12-09T10:54:51Z"
"revision": "870324b771df3ab35be9b881a1c4981260e18b5d",
"revisionTime": "2017-12-09T12:27:05Z"
},
{
"checksumSHA1": "Fnz7xSfgecNEaVi+I5a7HA1cl3I=",
......@@ -56,8 +56,8 @@
"checksumSHA1": "hTThB1Cw2ue02RD5Oig4eu1Dkzk=",
"origin": "git.autistici.org/id/usermetadb/vendor/github.com/cenkalti/backoff",
"path": "github.com/cenkalti/backoff",
"revision": "a5c1112b0e170bd76b30208f7b008277be32fc61",
"revisionTime": "2017-12-09T10:54:51Z"
"revision": "870324b771df3ab35be9b881a1c4981260e18b5d",
"revisionTime": "2017-12-09T12:27:05Z"
},
{
"checksumSHA1": "RBwpnMpfQt7Jo7YWrRph0Vwe+f0=",
......@@ -123,8 +123,8 @@
"checksumSHA1": "dr5+PfIRzXeN+l1VG+s0lea9qz8=",
"origin": "git.autistici.org/id/usermetadb/vendor/golang.org/x/net/context",
"path": "golang.org/x/net/context",
"revision": "a5c1112b0e170bd76b30208f7b008277be32fc61",
"revisionTime": "2017-12-09T10:54:51Z"
"revision": "870324b771df3ab35be9b881a1c4981260e18b5d",
"revisionTime": "2017-12-09T12:27:05Z"
},
{
"checksumSHA1": "xsaHqy6/sonLV6xIxTNh4FfkWbU=",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment