Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Accounts service for API keys #1506

Merged
merged 67 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
3f08891
Add a site property to explicitly enable health checks
Daniel-WWU-IT Nov 30, 2020
ed873af
Add changelog
Daniel-WWU-IT Nov 30, 2020
1ffc377
Add some more labels to Prometheus targets
Daniel-WWU-IT Dec 1, 2020
83ba2ca
Skip endpoints for BBE if no gRPC port is set
Daniel-WWU-IT Dec 1, 2020
5acfedd
Merge branch 'master-upstream'
Daniel-WWU-IT Dec 2, 2020
e895b9d
Merge branch 'master-upstream'
Daniel-WWU-IT Jan 4, 2021
d67790f
Minor TUS adjustments
Daniel-WWU-IT Jan 4, 2021
b9a5e49
Merge branch 'master-upstream'
Daniel-WWU-IT Jan 14, 2021
bf0b038
Set scheme for Prometheus targets
Daniel-WWU-IT Jan 14, 2021
5fe8350
Add site authorization status support
Daniel-WWU-IT Jan 15, 2021
7ec1186
Persist authorization status
Daniel-WWU-IT Jan 15, 2021
46b2d53
Admin API for site authorization
Daniel-WWU-IT Jan 15, 2021
c3e082e
Update changelog
Daniel-WWU-IT Jan 15, 2021
63836d1
Hound fix
Daniel-WWU-IT Jan 15, 2021
c39ee4f
Hound fix
Daniel-WWU-IT Jan 15, 2021
0fe77e7
Missing error check
Daniel-WWU-IT Jan 15, 2021
990af82
Expose site ID
Daniel-WWU-IT Jan 18, 2021
177b3bf
Update documentation and example
Daniel-WWU-IT Jan 18, 2021
1ed1822
Merge branch 'master-upstream'
Daniel-WWU-IT Jan 18, 2021
5839218
Make GenerateId private
Daniel-WWU-IT Jan 18, 2021
d6a74a2
Fix crash when (un)registering a site
Daniel-WWU-IT Jan 18, 2021
ce8356a
Merge branch 'master-upstream'
Daniel-WWU-IT Jan 19, 2021
dcc9a94
Use site ID field for authorization
Daniel-WWU-IT Jan 19, 2021
10e6c66
Merge branch 'master-upstream'
Daniel-WWU-IT Feb 5, 2021
ea1269d
Fix Mentix data cloning bug
Daniel-WWU-IT Feb 5, 2021
7ab6db2
Fix changelog
Daniel-WWU-IT Feb 5, 2021
af6e52c
Merge pull request #3 from cs3org/master
Daniel-WWU-IT Feb 16, 2021
26495e0
Begin work on new accounts service
Daniel-WWU-IT Feb 16, 2021
0516ceb
Implement account creation, update, removal endpoints
Daniel-WWU-IT Feb 16, 2021
7be2952
Add web interface panel
Daniel-WWU-IT Feb 17, 2021
92dd65a
Add API key generator and endpoints
Daniel-WWU-IT Feb 17, 2021
17a7b46
Add query endpoints
Daniel-WWU-IT Feb 18, 2021
314a3c8
Add API key verification
Daniel-WWU-IT Feb 18, 2021
6528962
Add email notifications
Daniel-WWU-IT Feb 18, 2021
f0981c2
Panel date fixes
Daniel-WWU-IT Feb 18, 2021
8739f98
Add notifications email option
Daniel-WWU-IT Feb 19, 2021
880835c
Create output directory for file storage
Daniel-WWU-IT Feb 19, 2021
fbb8706
Remove testing code
Daniel-WWU-IT Feb 19, 2021
4e15bd8
Add site ID generation
Daniel-WWU-IT Feb 22, 2021
a613c66
Remove admin endpoints
Daniel-WWU-IT Feb 23, 2021
bf4a13a
Site IDs are now stored in GOCDB
Daniel-WWU-IT Feb 23, 2021
55a1201
Cleanup
Daniel-WWU-IT Feb 23, 2021
46ffcef
Streamline request exchangers
Daniel-WWU-IT Feb 23, 2021
dc5f93c
Add site registration importer
Daniel-WWU-IT Feb 23, 2021
4e4211c
Enhance site ID security
Daniel-WWU-IT Feb 23, 2021
e695a28
Use accounts service for API key querying
Daniel-WWU-IT Feb 24, 2021
fcecdef
All exchangers now store the current mesh data
Daniel-WWU-IT Feb 24, 2021
5d1ff52
Check site existence on operations
Daniel-WWU-IT Feb 24, 2021
4d4a1c3
Pass config and log to request exchangers
Daniel-WWU-IT Feb 24, 2021
10a464d
Add email to registered sites
Daniel-WWU-IT Feb 24, 2021
c6d3a0b
Option to ignore registrations of ScienceMesh sites
Daniel-WWU-IT Feb 24, 2021
fd6cab8
Better accounts services initialization
Daniel-WWU-IT Feb 24, 2021
d6e7881
Extend is-authorized endpoint
Daniel-WWU-IT Feb 24, 2021
78a98d4
Add site authorization check
Daniel-WWU-IT Feb 24, 2021
e3e1e04
Check authorization status during all requests
Daniel-WWU-IT Feb 24, 2021
5ef9f6a
Remove WebAPI importer
Daniel-WWU-IT Feb 24, 2021
ddb935a
Use site ID as locations keys
Daniel-WWU-IT Feb 24, 2021
9a2ff86
Cleanup
Daniel-WWU-IT Feb 25, 2021
c5a861a
Cleanup
Daniel-WWU-IT Feb 25, 2021
2e724ca
Add/update examples
Daniel-WWU-IT Feb 25, 2021
cdf4852
Lint fixes
Daniel-WWU-IT Feb 25, 2021
6c0e740
Update documentation
Daniel-WWU-IT Feb 25, 2021
79f798c
Add changelog
Daniel-WWU-IT Mar 1, 2021
f2900ad
Hound fixes
Daniel-WWU-IT Mar 1, 2021
3c8f8c6
Hound fixes
Daniel-WWU-IT Mar 1, 2021
98f7bfa
Merge pull request #4 from cs3org/master
Daniel-WWU-IT Mar 1, 2021
064cf0a
Rename 'accounts' to 'siteacc'
Daniel-WWU-IT Mar 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/mentix-clone-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Cloning of internal mesh data lost some values

This update fixes a bug in Mentix that caused some (non-critical) values to be lost during data cloning that happens internally.

https://github.com/cs3org/reva/pull/1457
7 changes: 7 additions & 0 deletions changelog/unreleased/siteaccs-svc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Site Accounts service for API keys

This update adds a new service to Reva that handles site accounts creation and management. Registered sites can be assigned an API key through a simple web interface which is also part of this service. This API key can then be used to identify a user and his/her associated (vendor or partner) site.

Furthermore, Mentix was extended to make use of this new service. This way, all sites now have a stable and unique site ID that not only avoids ID collisions but also introduces a new layer of security (i.e., sites can only be modified or removed using the correct API key).

https://github.com/cs3org/reva/pull/1506
35 changes: 30 additions & 5 deletions docs/content/en/docs/config/http/services/mentix/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description: >
Mentix (_**Me**sh E**nti**ty E**x**changer_) is a service to read and write mesh topology data to and from one or more sources (e.g., a GOCDB instance) and export it to various targets like an HTTP endpoint or Prometheus.
{{% /pageinfo %}}

## General settings
{{% dir name="prefix" type="string" default="mentix" %}}
The relative root path of all exposed HTTP endpoints of Mentix.
{{< highlight toml >}}
Expand Down Expand Up @@ -42,11 +43,8 @@ Mentix can import mesh data from various sources and write it to one or more tar

__Supported importers:__

- **webapi**
Mentix can import mesh data via an HTTP endpoint using the `webapi` importer. Data can be sent to the configured relative endpoint (see [here](webapi)).

- **adminapi**
Some aspects of Mentix can be administered through an HTTP endpoint using the `adminapi` importer. Queries can be sent to the configured relative endpoint (see [here](adminapi)).
- **sitereg**
Mentix can import new sites via an HTTP endpoint using the `sitereg` importer. Data can be sent to the configured relative endpoint (see [here](sitereg)).

## Exporters
Mentix exposes its gathered data by using one or more _exporters_. Such exporters can, for example, write the data to a file in a specific format, or offer the data via an HTTP endpoint.
Expand All @@ -65,3 +63,30 @@ Mentix exposes its data via an HTTP endpoint using the `webapi` exporter. Data c
- files:
- '/usr/share/prom/sciencemesh_services.json'
```

## Site Accounts service
Mentix uses the Reva site accounts service to query information about site accounts. The following settings must be configured properly:

{{% dir name="url" type="string" default="" %}}
The URL of the site accounts service.
{{< highlight toml >}}
[http.services.mentix.accounts]
url = "https://example.com/accounts"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="user" type="string" default="" %}}
The user name to use for basic HTTP authentication.
{{< highlight toml >}}
[http.services.mentix.accounts]
user = "hans"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="password" type="string" default="" %}}
The user password to use for basic HTTP authentication.
{{< highlight toml >}}
[http.services.mentix.accounts]
password = "secret"
{{< /highlight >}}
{{% /dir %}}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "sitereg"
linkTitle: "sitereg"
weight: 10
description: >
Configuration for site registration service
---

{{% pageinfo %}}
The site registration service is used to register new and unregister existing sites.
{{% /pageinfo %}}

The site registration service is used to register new and unregister existing sites.

{{% dir name="endpoint" type="string" default="/sitereg" %}}
The endpoint of the service.
{{< highlight toml >}}
[http.services.mentix.importers.sitereg]
endpoint = "/reg"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="enabled_connectors" type="[]string" default="" %}}
A list of all enabled connectors for the importer.
{{< highlight toml >}}
[http.services.mentix.importers.sitereg]
enabled_connectors = ["localfile"]
{{< /highlight >}}
{{% /dir %}}

{{% dir name="ignore_sm_sites" type="bool" default="false" %}}
If set to true, registrations from ScienceMesh sites will be ignored.
{{< highlight toml >}}
[http.services.mentix.importers.sitereg]
ignore_sm_sites = true
{{< /highlight >}}
{{% /dir %}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,9 @@ description: >
---

{{% pageinfo %}}
The WebAPI of Mentix supports both importing and exporting of mesh data via an HTTP endpoint. Both the im- and exporter are configured separately.
The WebAPI of Mentix supports of mesh data via an HTTP endpoint.
{{% /pageinfo %}}

## Importer

The WebAPI importer receives a single _plain_ Mentix site through an HTTP `POST` request; service types are currently not supported.

The importer supports two actions that must be passed in the URL:
```
https://sciencemesh.example.com/mentix/webapi/?action=<value>
```
Currently, the following actions are supported:
- `register`: Registers a new site
- `unregister`: Unregisters an existing site

For all actions, the site data must be sent as JSON data. If the call succeeded, status 200 is returned.

{{% dir name="endpoint" type="string" default="/sites" %}}
The endpoint where the mesh data can be sent to.
{{< highlight toml >}}
[http.services.mentix.importers.webapi]
endpoint = "/data"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="is_protected" type="bool" default="false" %}}
Whether the endpoint requires authentication.
{{< highlight toml >}}
[http.services.mentix.importers.webapi]
is_protected = true
{{< /highlight >}}
{{% /dir %}}

{{% dir name="enabled_connectors" type="[]string" default="" %}}
A list of all enabled connectors for the importer. Must always be provided.
{{< highlight toml >}}
[http.services.mentix.importers.webapi]
enabled_connectors = ["localfile"]
{{< /highlight >}}
{{% /dir %}}

## Exporter

The WebAPI exporter exposes the _plain_ Mentix data via an HTTP endpoint.

{{% dir name="endpoint" type="string" default="/sites" %}}
Expand Down
95 changes: 95 additions & 0 deletions docs/content/en/docs/config/http/services/siteacc/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: "siteacc"
linkTitle: "siteacc"
weight: 10
description: >
Configuration for the Site Accounts service
---

{{% pageinfo %}}
The site accounts service is used to store and manage site accounts.
{{% /pageinfo %}}

## General settings
{{% dir name="prefix" type="string" default="accounts" %}}
The relative root path of all exposed HTTP endpoints of the service.
{{< highlight toml >}}
[http.services.siteacc]
prefix = "/siteacc"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="notifications_mail" type="string" default="" %}}
An email address where all notifications are sent to.
{{< highlight toml >}}
[http.services.siteacc]
notifications_mail = "[email protected]"
{{< /highlight >}}
{{% /dir %}}

## SMTP settings
{{% dir name="sender_mail" type="string" default="" %}}
An email address from which all emails are sent.
{{< highlight toml >}}
[http.services.siteacc.smtp]
sender_mail = "[email protected]"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="sender_login" type="string" default="" %}}
The login name.
{{< highlight toml >}}
[http.services.siteacc.smtp]
sender_login = "hans"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="sender_password" type="string" default="" %}}
The password for the login.
{{< highlight toml >}}
[http.services.siteacc.smtp]
password = "secret"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="smtp_server" type="string" default="" %}}
The SMTP server to use.
{{< highlight toml >}}
[http.services.siteacc.smtp]
smtp_server = "smtp.example.com"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="smtp_port" type="int" default="25" %}}
The SMTP server port to use.
{{< highlight toml >}}
[http.services.siteacc.smtp]
smtp_port = 25
{{< /highlight >}}
{{% /dir %}}

{{% dir name="disable_auth" type="bool" default="false" %}}
Whether to disable authentication.
{{< highlight toml >}}
[http.services.siteacc.smtp]
disable_auth = true
{{< /highlight >}}
{{% /dir %}}

## Storage settings
{{% dir name="driver" type="string" default="file" %}}
The storage driver to use; currently, only `file` is supported.
{{< highlight toml >}}
[http.services.siteacc.storage]
driver = "file"
{{< /highlight >}}
{{% /dir %}}

### Storage settings - File driver
{{% dir name="file" type="string" default="" %}}
The file location.
{{< highlight toml >}}
[http.services.siteacc.storage.file]
file = "/var/reva/accounts.json"
{{< /highlight >}}
{{% /dir %}}
23 changes: 11 additions & 12 deletions examples/mentix/mentix.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[shared]
jwt_secret = "Ment1x-T0pS3cr3t"

[http]
address = "0.0.0.0:9600"
enabled_services = ["mentix"]

[http.services.mentix]
update_interval = "15m"
Expand All @@ -25,16 +21,19 @@ endpoint = "/"
# If this setting is omitted, all connectors will be used as data sources
enabled_connectors = ["gocdb"]

# Enable the WebAPI importer
[http.services.mentix.importers.webapi]
# Enable the site registration importer
[http.services.mentix.importers.sitereg]
# For importers, this is obligatory; the connectors will be used as the target for data updates
enabled_connectors = ["localfile"]

# Enable the AdminAPI importer
[http.services.mentix.importers.adminapi]
enabled_connectors = ["localfile"]
# Should never allow access w/o prior authorization
is_protected = true
# If set to true, ScienceMesh sites will be ignored when they try to register
ignore_sm_sites = false

# Set up the accounts service used to query information about accounts associated with registered sites
[http.services.mentix.accounts]
# Depending on where the service is running, localhost may also be used here
url = "https://sciencemesh.example.com/iop/accounts"
user = "username"
password = "userpass"

# Configure the Prometheus Service Discovery:
[http.services.mentix.exporters.promsd]
Expand Down
19 changes: 19 additions & 0 deletions examples/siteacc/siteacc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[http]
address = "0.0.0.0:9600"

[http.services.siteacc]
# All notification emails are sent to this email
notifications_mail = "[email protected]"

# Set up the storage driver
[http.services.siteacc.storage]
driver = "file"
[http.services.siteacc.storage.file]
file = "/var/revad/accounts.json"

# The SMTP server used for sending emails
[http.services.siteacc.smtp]
sender_mail = "[email protected]"
smtp_server = "mail.example.com"
smtp_port = 25
disable_auth = true
1 change: 1 addition & 0 deletions internal/http/services/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
_ "github.com/cs3org/reva/internal/http/services/owncloud/ocdav"
_ "github.com/cs3org/reva/internal/http/services/owncloud/ocs"
_ "github.com/cs3org/reva/internal/http/services/prometheus"
_ "github.com/cs3org/reva/internal/http/services/siteacc"
_ "github.com/cs3org/reva/internal/http/services/sysinfo"
_ "github.com/cs3org/reva/internal/http/services/wellknown"
// Add your own service here
Expand Down
8 changes: 2 additions & 6 deletions internal/http/services/mentix/mentix.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,8 @@ func applyDefaultConfig(conf *config.Configuration) {
}

// Importers
if conf.Importers.WebAPI.Endpoint == "" {
conf.Importers.WebAPI.Endpoint = "/sites"
}

if conf.Importers.AdminAPI.Endpoint == "" {
conf.Importers.AdminAPI.Endpoint = "/admin"
if conf.Importers.SiteRegistration.Endpoint == "" {
conf.Importers.SiteRegistration.Endpoint = "/sitereg"
}

// Exporters
Expand Down
Loading