-
Notifications
You must be signed in to change notification settings - Fork 4
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
Token authentication #4
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
def build_token | ||
ts = Time.now.to_i | ||
payload = { iss: account_id, iat: ts - 5, exp: ts + 64 } | ||
JWT.encode(payload, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWT gem is not in dependencies, this may break if one does not have it already
@@ -51,6 +54,15 @@ def method_missing(name, *args) | |||
|
|||
protected | |||
|
|||
def build_token | |||
ts = Time.now.to_i | |||
payload = { iss: account_id, iat: ts - 5, exp: ts + 64 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide more info on why we need "issued at" field in past
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just copied behaviour from their own python client
@api_key = options[:api_key] | ||
@private_key = options[:private_key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably here should be a check that only one auth method is enabled at a time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, client can use both kind of auth methods at same time. If so, the decision of is request authenticated or not will be completely on api provider side. We can perform validation for at least one auth method provided during client initialization, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"at least one" sounds good
Introduce modern authorization mechanism instead of deprecated one.