-
Notifications
You must be signed in to change notification settings - Fork 39
[PECO-728] Add OAuth support #147
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
Conversation
26f2ffe
to
e600b7b
Compare
Signed-off-by: Levko Kravets <[email protected]>
e600b7b
to
9bf2327
Compare
…lAuthentication Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
5effef8
to
7c15742
Compare
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #147 +/- ##
==========================================
- Coverage 96.28% 96.21% -0.07%
==========================================
Files 50 54 +4
Lines 808 952 +144
Branches 134 160 +26
==========================================
+ Hits 778 916 +138
- Misses 9 10 +1
- Partials 21 26 +5
☔ View full report in Codecov by Sentry. |
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.
Overall looks good, I just have a couple questions
port: number, | ||
requestHandler: (req: IncomingMessage, res: ServerResponse) => void, | ||
): Promise<Server> { | ||
const server = http.createServer(requestHandler); |
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.
Could this ever create issues of trying to send an https request from an http server?
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.
OAuth app we use is configured to allow http only. But it's not an issue, because we receive only authorization token via callback url, and then use that auth token + verifier string in another request to OAuth endpoint to obtain access and refresh tokens. All OAuth endpoints use https. So even is anyone will intercept auth code - it's basically useles without verifier which is not exposed anywhere
} | ||
|
||
return new Promise((resolve, reject) => { | ||
const errorListener = (error: Error) => { |
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.
This syntax is really strange to me, where did you get this? The errorListener invokes server off with itself?
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.
Here (and similarly in startServer
) I just "promisify" server methods. Node's http server has event-based API, but since all our code is Promise-based, I wrapped server creation and stopping routines. How it works: first I create an error handler function and attach it to server's error
event. Then I invoke a method I need, and if it was successful - I remove that error listener (therefore I store it in variable), and resolve promise. If called method emits an error - my error handler catches it, removes itself and rejects promise. Error handler here is needed only once to handle a single error, therefore I keep a function to be able to unregister it once it's no longer needed
* [PECO-728] Add OAuth support Signed-off-by: Levko Kravets <[email protected]> * Cleanup DBSQLClient code; remove redundant and no longer needed NoSaslAuthentication Signed-off-by: Levko Kravets <[email protected]> * DBSQLClient: options for auth types Signed-off-by: Levko Kravets <[email protected]> * Tests Signed-off-by: Levko Kravets <[email protected]> * Tests Signed-off-by: Levko Kravets <[email protected]> * Fix: move comment to appropriate place Signed-off-by: Levko Kravets <[email protected]> * Improve tests Signed-off-by: Levko Kravets <[email protected]> * Use proper client ID; improve callback handling Signed-off-by: Levko Kravets <[email protected]> --------- Signed-off-by: Levko Kravets <[email protected]> Signed-off-by: nithinkdb <[email protected]>
PECO-728 Add OAuth support
Related to (and partially based on) databricks/databricks-sql-python#15