-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add ID token verification endpoint #253
Conversation
We may also need By the way, there is no way to check/change LIFF app's scope 😕 |
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.
Thanks for sending in your pull request! I have commented on a few of them and would appreciate your checking.
lib/line/bot/client.rb
Outdated
# @param options [Hash] Optional request body | ||
# | ||
# @return [Net::HTTPResponse] | ||
def verify_id_token(id_token, options = {}) |
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.
Passing options as a hash may result in unintended parameters being passed to the endpoint. It may be too much to worry about, but it is better to be safe than sorry.
I think it would be better to pass only concrete parameters, i.e. nonce
and user_id
, like other methods such as narrowcast.
line-bot-sdk-ruby/lib/line/bot/client.rb
Line 257 in 8760add
def narrowcast(messages, recipient: nil, filter: nil, limit: nil, headers: {}) |
def verify_id_token(id_token, options = {}) | |
def verify_id_token(id_token, nonce: nil, user_id: nil) |
|
||
it 'verifies ID token' do | ||
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_OAUTH_ENDPOINT + '/oauth2/v2.1/verify' | ||
stub_request(:post, uri_template).to_return { |request| {body: '', status: 200} } |
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.
In the test, the body of the response is empty, but it actually returns the contents of the ID token. I think it would be better to add content validation for some values, referring to the "Example response" in the documentation.
https://developers.line.biz/en/reference/line-login/#verify-id-token-response
addressed @zenizh's reveiw and add implementation for verify_access_token and get_profile_by_access_token |
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 your response. I think it is very nice. I made one minor comment, please check it when you have a chance.
# @param access_token [String] access token | ||
# | ||
# @return [Net::HTTPResponse] | ||
def verify_access_token(access_token) |
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.
https://developers.line.biz/en/reference/line-login-v2/#verify-access-token
There is v2 version of this API.
Should I rename this to verify_access_token_v2_1
?
I named this way since I thought v2.1 is superset of v2.
Same for get_profile_by_access_token
.
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 think verify_access_token
is fine. Because LINE Login v2.0 is deprecated. Also, the documentation comment says "Verify access token v2.1", so it seems that users will not have to worry about it.
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.
LGTM! Thanks for your contribution!
@yskkin I'll be releasing a version next week that includes this change. Sorry for the wait! |
This is implementation for https://developers.line.biz/en/reference/line-login/#verify-id-token.
We need this for
liff.getIDToken()
.