-
Notifications
You must be signed in to change notification settings - Fork 350
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
Credential insert by name #490
Conversation
4cda157
to
4b8053f
Compare
5f766c6
to
2b718c9
Compare
b219784
to
d9cbf67
Compare
d9cbf67
to
bd08c1a
Compare
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.
want to understand this more carefully - if the admin does eg credentials create -c username
from now on - this will work, but you're saying if an admin had done this in the past it won't work?
@altsang Yes. That's why I wrote that it might be a breaking change. Master branch: With this PR, if you call the CLI with Given this change, all the previous (and wrong) credentials stored with username won't be accessible anymore (because of this translation). We could:
I'm open to other possibilities of course — I just wanted to understand what's your intention first. |
Codecov Report
@@ Coverage Diff @@
## master #490 +/- ##
========================================
- Coverage 92.01% 92% -0.02%
========================================
Files 219 219
Lines 9271 9280 +9
========================================
+ Hits 8531 8538 +7
- Misses 740 742 +2
Continue to review full report at Codecov.
|
We agreed we'll create a That'll need #492 to be completed. |
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.
one small note about status code and then LGTM
I've tried in CLI, it works
lib/rest/routes/credentials.js
Outdated
findConsumer(req.params.consumerId) | ||
.then((consumer) => { | ||
if (!consumer) { | ||
return res.status(422).json(new Error('Consumer Not Found: id:' + req.body.consumerId)); |
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.
422 is kind of form validation. it should be 404, since no consumer exists
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.
That's absolutely correct. 422 means "not processable" entity.
I'll candidly admit I have no idea why the coverage is decreasing and how to put it back and make it pass. |
…ial-name-second-try Credential insert by name
Connects #361 closes #361
Attempt 2 after #488 failure.
Review without whitespace will make the job easier: https://github.com/ExpressGateway/express-gateway/pull/490/files?w=1
What's up?
The following PR|Monster|Dragoon will change the way credentials are stored and retrieved with regards of the consumers.
In particular:
On the CLI, whether you're doing
-c username
or-c id
, now a consumer lookup will be performed, therefore all the operations will be performed on the same entity. Theid
will always be the source of truth for all the subsequent operations.For basic auth, the credential id IS the key id. This is not limiting anything as the gateway today is supporting 1 basic-auth key per consumer. We can change this behaviour in the future eventually.
Update all the tests to use
user.id
instead of the username when looking up for the credentials.Warning
As this is fixing a wrong behavior, This might be a breaking change for existing users.
What what?
If an user created a credential in this way:
eg credentials create -c userName
It won't be found anymore by the system, since usernames are now "transformed" into their IDs first, and then the credential is retrieved/stored/bla bla.
As I do not know how many people are relying on this, we need to discuss whether this is a breaking change or a simple bugfix (hopefully the latter)