Skip to content
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

Support for Authentication on HTTPS requests #31

Open
aneuway2 opened this issue Sep 29, 2022 · 0 comments
Open

Support for Authentication on HTTPS requests #31

aneuway2 opened this issue Sep 29, 2022 · 0 comments

Comments

@aneuway2
Copy link

Would it be possible to add support for basic authentication for HTTPS requests (or other methods like cookie auth/etc)?

I'm tinkering around with the code but its been a long while since I've been in Java. I think something like this would need to be added to the HttpCSVReader.java to support that:

	public Reader getReader(Statement statement, String tableName) throws SQLException {
	    try
	    {
	      CsvConnection conn = ((CsvConnection) statement.getConnection());
	    	
	      URL url = new URL(conn.getCustomBaseUrl() + tableName + conn.getExtension());
	      HttpURLConnection connection = (HttpURLConnection) url.openConnection();

		  // Authentication
		  String username ="[email protected]";
		  String password = "12345678";
		  String auth =new String(username + ":" + password);
		  byte[] data1 = auth.getBytes(UTF_8);
		  String base64 = Base64.encodeToString(data1, Base64.NO_WRAP);
		  urlConnection.addRequestProperty("Authorization", "Basic "+base64);
	      InputStreamReader reader = new InputStreamReader(connection.getInputStream());
	      return reader;
	    }
	    catch (Exception e)
	    {
	      throw new SQLException(e.getMessage());
	    }
	}

But im not sure how to build the project or how to properly pass in the credentials from the frontend.

Also happy to try to create a PR with some assistance :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant