-
Notifications
You must be signed in to change notification settings - Fork 19
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 support for Application ID auth pattern #58
Conversation
e2d4d3c
to
7346a69
Compare
These overrides are required as a fix to workaround istio/istio#11226 dep: Migrate to latest revision of istio 1.1
7346a69
to
bca4a4a
Compare
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
==========================================
+ Coverage 85.61% 86.75% +1.14%
==========================================
Files 3 3
Lines 438 438
==========================================
+ Hits 375 380 +5
+ Misses 40 37 -3
+ Partials 23 21 -2
Continue to review full report at Codecov.
|
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.
Check comments - since we will be detecting the authn used, we want to be lenient about existing parameters (ie. ignoring them) and use a specific priority order.
user: request.query_params["user_key"] | request.headers["x-user-key"] | request.api_key | "" | ||
properties: | ||
app_id: request.query_params["app_id"] | request.headers["x-app-id"] | "" | ||
app_key: request.query_params["app_key"] | request.headers["x-app-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.
we've been talking about this, but just to rule out this last thought of mine out of being a bit naive: setting here a property like query: request.query_params
(the whole map) does not work, does 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.
I couldn't get that to work. Thats what I thought initially. Cant seem to have nested maps. I will try out some other stuff in the mean time but it wont be hard to go from this to a working alternative.
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.
we could be interested in knowing whether these parameters are empty or they weren't specified, perhaps we can leave out the ""
and test for nil
?
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.
(for a bit of context, there is in 3scale, under certain conditions, a semantic difference between specifying an empty app_key
to the Service Management API and simply not specifying it at all)
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 don't think that's going to be achievable with the current client. The default string value in go is ""
.
When we create the params, even if we don't set it it will become empty string. I think would need to go ahead and use pointers to strings in the client to get this behaviour.
Happy to create an issue on it and fix, but my suggestion is leave this as is for now, wdyt?
server *grpc.Server | ||
client *http.Client | ||
conf *AdapterConfig | ||
} |
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.
Not sure if it's more idiomatic to group these together in golang, I personally prefer to have the definition next to the implementation of methods, perhaps one struct + methods per file (as in Java) to have all the information together for easy reference, but I don't have a strong opinion in this particular case (just FYI in case you didn't consider alternatives).
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.
Well this is not uncommon in go. Even the stdlib uses types.go
files. The reason I have done this is looking ahead slightly.
I spoke to @jmprusi who has a use cause for decoupling the actual so I expect some refactoring, but I'm ok with putting these back where they were if you like. Once the type methods aren't spread across files I'm fine either way.
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.
No, it's ok this way, I just FYI'ed it. :)
Decoupling this from its context... well, it's going to cost a bit. Let @jmprusi volunteer to extract the logic out and make it available for us as a shared library. :D
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.
}, | ||
}, | ||
}, | ||
expect: generatedExpectedError(t, rpc.PERMISSION_DENIED, authMismatchErr), |
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'd say we prefer this to be "I will use user_key=MATCH
and ignore app_key
".
We can define this order:
- Presence of user_key? => process user_key, goto 3
- Presence of app_id? => goto 2.a
2.a Presence of app_key? => process app_id with app_key, goto 3
2.b Process app_id without app_key - Done.
Of course, if we knew we were supposed to only be using app_id/app_key, we'd be ignoring the other steps (ie. 1).
Value: proxyConf.Content.BackendAuthenticationValue, | ||
}} | ||
|
||
if request.Subject != nil { |
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.
if Subject == nil
we can probably error out earlier, before matching rules, right?
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.
True, Again this is just covering a messed up config and avoiding a panic but yes, I'll move this to fail early
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.
Fixed
bca4a4a
to
73d2f92
Compare
73d2f92
to
fddb161
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.
Looking better, check comments.
user: request.query_params["user_key"] | request.headers["x-user-key"] | request.api_key | "" | ||
properties: | ||
app_id: request.query_params["app_id"] | request.headers["x-app-id"] | "" | ||
app_key: request.query_params["app_key"] | request.headers["x-app-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.
we could be interested in knowing whether these parameters are empty or they weren't specified, perhaps we can leave out the ""
and test for nil
?
user: request.query_params["user_key"] | request.headers["x-user-key"] | request.api_key | "" | ||
properties: | ||
app_id: request.query_params["app_id"] | request.headers["x-app-id"] | "" | ||
app_key: request.query_params["app_key"] | request.headers["x-app-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.
(for a bit of context, there is in 3scale, under certain conditions, a semantic difference between specifying an empty app_key
to the Service Management API and simply not specifying it at all)
bab979e
to
f35ba2b
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.
Looks good, check comments for minor things to correct.
README.md
Outdated
Now that the we have [configured the service to be managed by 3scale](#routing-service-traffic-through-the-adapter) we can decide how requests should be authenticated. | ||
Currently there are two supported mechanisms: | ||
1. The API Key authentication pattern | ||
1. The Application ID authentication pattern |
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 mention the "pair" of App ID and App Key, as it is referred to like this in docs. Also, this should be 2
.
method: request.method | "get" | ||
``` | ||
|
||
#### Hybrid Pattern |
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.
👍
669aced
to
ed3ae64
Compare
This change updates the handler to support an additional authentication method. The instance will be configured by the user and the adapter parses the request to determine what authentication method should be used and in turn decides on the 3scale backend API which will be called.
ed3ae64
to
434fc2e
Compare
This change alerts the operator to the fact that the config has no changed to use features from Istio version 1.1 which becomes a prerequisite. Also included are updates to the README to describe how to configure the various authentication patterns and how to adjust the config to enforce various authn methods.
434fc2e
to
e83a665
Compare
Moves to 1.1 codebase
Post review/approval
TODO - Verification Steps