opensearch-project / sql-odbc

OpenSearchODBC is a read-only ODBC driver for Windows and Mac for connecting to OpenSearch SQL support.
Apache License 2.0
7 stars 17 forks source link

Oauth2 feature added #67

Open fepatrifork opened 6 months ago

fepatrifork commented 6 months ago

Description

These changes add the capability to manage the Oauth2 authentication/authorization using JWT token provided by an IdP. The modification involves different levels of the system that is possible to refer as frontend for the part of the powerBI connector that is defined in Power Query (M) and backend for the part that contains the ODBC driver logic. The modification on the frontend (PowerBI connector) comprehends the management of the Authorization Code Flow "OAUTH2" using the predefined callbacks StartLogin, FinishLogin, Refresh, Logout and the configuration of the flow comes from a JSON file (template provided). This level passes the token to the backend (ODBC driver) that manages the information received to make an HTTP request with a different header. The modification includes the" ODBC Data Sources Administrator" that now allows the selection of the "OAUTH2" option for inserting a token in a created field and testing the connection. The modification of the token information has a similar treatment of the password in "BASIC" during the whole logic, with adapting due to the string size of the token. After installing the re-packaged .msi file, a system test was settled and passed using "PowerBI Desktop" and in " ODBC Data Sources Administrator" with a localhost database. The result of unit-test integration-test are made with the provided script test_runner.py modified to exclude .recipe extension that does not allow running all the tests. Test cases, documentation, user manual and DCO can be provided and expanded if there is an interest in this work and you consider it valuable.

Issues Resolved

Added Oauth2 feature

Check List

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

rupal-bq commented 6 months ago

Can you please take a look at failed CI?

fepatrifork commented 6 months ago

Can you please take a look at failed CI?

I take care of the followings:

Looking forward for feedback after re-CI!

rupal-bq commented 6 months ago

@fepatrifork Thanks for looking into CI failures. Can you please also add test cases, documentation and user manual?

fepatrifork commented 6 months ago

@fepatrifork Thanks for looking into CI failures. Can you please also add test cases, documentation and user manual?

You're welcome. I see some other error:

  1. Link Checker now should finally ok with the last push
  2. Can you provide help with the error of cppcheck? Before was a clear error, now it seems all ok, but do not pass the test.

For the next steps:

  1. [x] For documentation and user manual I can integrate and enrich the pre-existent .md file for PowerBI connector and for the driver. Is that ok?
  2. [x] For the test cases will take some time.
    • SOLUTION: Added tests in test_conn.cpp in UnitTests and an IntegrationTest in ITODBCOauth folder. Integration test use a function that make a request to the IdP with client-credentials flow to get the token. Of course is fitted for our system, if you have an active webAPI with an IdP that can be reached with a test user, it will be perfect.
rupal-bq commented 6 months ago

Can you provide help with the error of cppcheck? Before was a clear error, now it seems all ok, but do not pass the test:

Sure, I'll take a look

For documentation and user manual I can integrate and enrich the pre-existent .md file for PowerBI connector and for the driver. Is that ok?

Yes

fepatrifork commented 5 months ago