这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ZIMkaRU
Copy link
Member

@ZIMkaRU ZIMkaRU commented Apr 6, 2023

This PR adds ability to set the selected TTL of the bfx auth token


The flow:

  • on sign-up authTokenTTLSec param can be passed to specify the auth token TTL to override the default value 24h, available values between 24h and 7 days
    • signUp request
    {
      "method": "signUp",
      "auth": {
        "authToken": "pub:api:12345678-1234-4321-5678-12ab3ba45ab6-caps:s:o:f:w:wd:a-write",
        "isNotProtected": true
      },
      "params": {
        "authTokenTTLSec": 604800
      }
    }
    • if the value is out of the allowed range an error would be thrown, signUp response:
    {
      "jsonrpc": "2.0",
      "error": {
        "code": 400,
        "message": "Auth token TTL has been set to disallowed value",
        "data": null
      },
      "id": null
    }
  • the next time, the auth token TTL can be fetched with signIn call, response example:
    {
      "jsonrpc": "2.0",
      "result": {
        "email": "user@email.com",
        "isSubAccount": false,
        "token": "12345678-1234-4321-5678-a1b234567890",
        "shouldNotSyncOnStartupAfterUpdate": false,
        "authTokenTTLSec": 604800
      },
      "id": null
    }
  • to modify the auth token TTL may be used the updateUser endpoint
    • updateUser request
    {
        "auth": {
          "token": "12345678-1234-4321-5678-a1b234567890"
        },
        "method": "updateUser",
        "params": {
          "authTokenTTLSec": 601200
        }
    }
    • updateUser response
    {
      "jsonrpc": "2.0",
      "result": true,
      "id": null
    }
  • if the value is out of the allowed range an error would be thrown:
    {
      "jsonrpc": "2.0",
      "error": {
        "code": 400,
        "message": "Auth token TTL has been set to disallowed value",
        "data": null
      },
      "id": null
    }

Basic changes:

  • adds ability to override the default value 24h of the bfx auth token ttl
  • adds ability to set authTokenTTLSec on sign-up
  • adds ability to return authTokenTTLSec when sign-in
  • adds ability to modify authTokenTTLSec field by updateUser method
  • adds v34 DB migration
  • adds corresponding test coverage
  • fixes getWeightedAveragesReport test case

assert.isBoolean(res.body.result.nextPage)

const resItem = res.body.result[0]
const resItem = res.body.result.res[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a fix not related to the PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix getWeightedAveragesReport test case: 44cf79b
yes, it's stuck from the previous PR
this is not a significant fix, decided not to separate it into a separate PR

Copy link
Contributor

@ezewer ezewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants