node-oauth2-server
node-oauth2-server copied to clipboard
User's IP in saveToken and generateAccessToken
How can I access to User's IP in saveToken and generateAccessToken ?
@thomasdashney , @mjsalinger Context must be passed as an argument to methods
After 6 days , No response 😢
I did it with scope parameter ( it passed to generateAccessToken ) Agree that scope have different thing but for now there is only one way to pass additional parameters to be added to token claims
@Doom100500 thanks, good idea for temporary solution Still I believe that context must be passed to all methods
@sm2017 , I'm sorry to tell that scope request parameter not passed to generateAccessToken on refresh_token grant type. For this case, i think saving the ip for token in DB can be workaround...
@Doom100500 thank you
@oauthjs Why no author/contributor of this reposit responses this issue Someone must assign issues
Nooo way, it just not working with the current flow. To get additional claims to be embedded to the generated access token is just not possible with the current flow. There is really missing some context to available during request. I didn't found a way to pass the additional claims for two grand types (password and refresh_token) i just getting lost on calls to model methods. And no way to share it in the model without an additional state existing during the request. The bottom line - we cannot use scope to configure payload of the access token. It must be another way...
I found the reason why the scope not passed to generateAccessToken on 'refresh_token' grant_type.
In refresh-token-grant-type.js
change return this.saveToken(token.user, client, token.scope);
to return this.saveToken(token.user, client, request.body.scope);
solved the problem.
It is seems like bug. But no hope it will be fixed, or pull request will be accepted. The repo seems dead last 3 - 4 months
created a pull request: #540
for temporary working solution:
npm i https://github.com/Doom100500/node-oauth2-server.git
@sm2017 +1
@joaogranado @lfk @maxtruxa @mjsalinger @ruimarinho @ruipenso @thomseddon
Is oauthjs/node-oauth2-server library abandoned?
@sm2017 have you had any luck with this ? I'm currently trying achieve the same thing
@rcauquil-pycom I forked this library in a private repository and customized it for my use case
@sm2017 ok thanks, what have you done to be able to get the req scope inside the model ?