mdouchement / standardfile

Yet Another Standardfile (standardnotes server) Implementation written in Golang
MIT License
79 stars 9 forks source link

Loads subscription's features from the configuration file #91

Closed mdouchement closed 10 months ago

mdouchement commented 1 year ago

The PR #90 provides the initial support of subscription's features requested by #74.

The project mdouchement/standardfile does not intend to update this list of features. In order to ease the updates of the features by everyone using this project, let's move the JSON payload to the configuration file along an explanation on how to extract it from official projet.


The new implementation should read the JSON exported from the https://github.com/standardnotes API:

It will update the IDs inside the JSON to match the user's ones like it's done in #90.

The configuration option should change from enable_subscriptions: false to:

suscription_feature_set: |
  {
    "meta": {
      "auth": {
        "userUuid": "some-user-uuid-v4",
        "roles": [
          {
            {
              "uuid": "8047edbb-a10a-4ff8-8d53-c2cae600a8e8",
              "name": "PRO_USER"
            },
            {
              "uuid": "8802d6a3-b97c-4b25-968a-8fb21c65c3a1",
              "name": "BASIC_USER"
            }
          }
        ]
      }
    }
  },
  and so one...

Then the subscriptions controller should be activated only when suscription_feature_set != "".

BobWs commented 1 year ago

Hi, I'm testing your server on Synology NAS (docker) but I don't know how to enable the subscription feature? I don't understand any of this what is written here.

Is there a way to explain it a bit more in dept? A small tutorial for example? TIA

mdouchement commented 1 year ago

This is an issue for improvement. Currently there is this option https://github.com/mdouchement/standardfile/blob/12038cd74a92ea591e55e32e4402a0d05c329a02/standardfile.yml#L25-L36

BobWs commented 1 year ago

I have tried to set enable_subscription: false to enable_subscription: "" but that isn't working. Then I've tried this:

# This project https://github.com/mdouchement/standardfile does not intend to
# conflict with the business model of StandardNotes project or seek compensation.
suscription_feature_set: |
  {
    "meta": {
      "auth": {
        "userUuid": "1f2e1521-4279-4a5e-b53b-007bcaa068a0",
        "roles": [
          {
            {
              "uuid": "1f2e1521-4279-4a5e-b53b-007bcaa068a0",
              "name": "PRO_USER"
            },
            {
              "uuid": "1f2e1521-4279-4a5e-b53b-007bcaa068a0",
              "name": "BASIC_USER"
            }
          }
        ]
      }
    }
  },

But that is not working also! I'm see this in my logs:

⇨ http server started on [::]:8093
2022/11/03 10:11:55 Server listening on :8093
2022/11/03 10:12:04 Error [ECHO]: %!s(<nil>)
[404] GET /v1/users/1f2e1521-4279-4a5e-b53b-007bcaa068a0/subscription (0) 2.648585ms
[401] GET /v2/subscriptions (0) 49.445µs
[200] POST /v1/items (85) 4.191502ms
[200] POST /v1/items (85) 629.699µs
2022/11/03 10:12:04 Error [ECHO]: %!s(<nil>)
[404] POST /v1/items/check-integrity (388) 363.264µs
200] POST /v1/items (85) 850.991µs
2022/11/03 10:12:14 Error [ECHO]: %!s(<nil>)
[404] POST /v1/subscription-tokens (0) 397.596µs
2022/11/03 10:12:15 Error [ECHO]: %!s(<nil>)
[404] POST /v1/subscription-tokens (0) 379.627µs
[401] GET /v1/users/:id/attributes/credentials (0) 92.247µs
mdouchement commented 1 year ago

This issue does not tell how to activate the feature, it's an improvement idea that may be implemented. Currently, there is just to put the boolean to true enable_subscription: true.

BobWs commented 1 year ago

So as I understand is doesn't work at the moment? If so will you implement this eventually?

I still have the original Standardnotes Self-host solution containers on my Synology NAS, but I was looking for a "one" server solutions instead of the "thousands" containers Standardnotes now has, and also everytime they update their images something is broke again.

mdouchement commented 1 year ago

It currently works with enable_subscription: true in the configuration file.

There is nothing to do with this issue (https://github.com/mdouchement/standardfile/issues/91) which is a potential evolution of the implementation.

BobWs commented 1 year ago

It currently works with enable_subscription: true in the configuration file.

Okay thanks!, so now it is working after setting enable_subscription: true Except for one extension (Markdown Alternative) all the embedded extensions are unlocked and working. Screen_Shot Any idea why that one is not working?

One other question about the standardfile.yml file. Do I need add anything for the secert-key and secert

# If missing, will be read from $CREDENTIALS_DIRECTORY/secret_key file
secret_key: jwt-development
# Session used for authentication (since 004 and 20200115)
session:
  # If missing, will be read from $CREDENTIALS_DIRECTORY/session.secret file
  secret: paseto-development
  access_token_ttl: 1440h # 60 days expressed in Golang's time.Duration format
  refresh_token_ttl: 8760h # 1 year
mdouchement commented 1 year ago

Any idea why that one is not working?

Yes because the JSON returned does not contain this feature I guess, that's why the issue #91 is open.

Do I need add anything for the secert-key and secert

Yes it's need, it's used to generate authentication tokens, it must be a random values for each field. Once these values are defined, it should never change.