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

remove user and password from DSN record #305

Merged
merged 7 commits into from
Jun 29, 2020

Conversation

akdor1154
Copy link
Contributor

Hey,
This PR removes auth stuff from the DSN record of the Connection struct. Instead it is passed in at connection time them forgotten. Two rationales:

  • the password is sensitive information and it's really easy at the moment to have it printed by mistake to e.g. notebook output.
  • allows to standardize the (dsn; user, pass) method to work on both DSN names and raw connection strings

Additionally, it allows me to add an extraauth parameter which is appended as-is and likewise treated as sensitive info. This will be database specific, and could be used for e.g. auth tokens, Snowflake warehouse specification, etc etc, basically things for where my code's connection string needs to be the same per-user, but users may still need to put account-specific config to get a DB connection. (This model actually follows how PowerBI models ODBC connections, and I figure that they have done a bit more solution design across different DBs than I have :) )

Added public API:

function Connection(dsn::AbstractString; user=nothing, password=nothing, extraauth=nothing)

Tests added and checked against MariaDB locally (we'll see what Travis says).. I will do further testing if Travis passes.

Any and all feedback welcome, this is my first public work in Julia so there are probably style issues at the very least.

@codecov
Copy link

codecov bot commented Jun 20, 2020

Codecov Report

Merging #305 into master will increase coverage by 0.17%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #305      +/-   ##
==========================================
+ Coverage   78.24%   78.42%   +0.17%     
==========================================
  Files           6        6              
  Lines         754      760       +6     
==========================================
+ Hits          590      596       +6     
  Misses        164      164              
Impacted Files Coverage Δ
src/dbinterface.jl 93.67% <87.50%> (+0.22%) ⬆️
src/API.jl 67.35% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1a98de...7f339f9. Read the comment docs.

Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of these changes. It seems you're probably still working on stuff right now, right? For example, I don't see the user/password fields removed from the Connection struct yet?

The extraauth stuff seems fine to me as well. I get a little nervous changing some of that stuff just because (as you may know) differences between drivers can be pretty finicky. But in general, the changes you have there look fine.

Just ping me here once you think this is ready to review/merge!

src/API.jl Outdated Show resolved Hide resolved
src/API.jl Outdated
# however there seems no standard way to escape PWD=mypass}hasacurly. (SQL server wants double }}, but other drivers differ).
function getextraauth(usr::Union{AbstractString, Nothing}, pwd::Union{AbstractString, Nothing}, extraauth::Union{AbstractString, Nothing}) :: String
return join([
usr === nothing ? "" : "UID={$usr}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more escaping that we had before! So I say we run w/ this for now; the nice thing is that people can always just pass the whole connection string themselves if they want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woop. I did have one thought on this - my change is technically a breaking change for any user who is currently passing their password manually like connect(dsn, "root", "{im escaping my pwd myself}"). Do you have any thoughts on that? it's a bit of an edge case and I can't see any issues discussing it so maybe no-one has hit it yet.

README.md Show resolved Hide resolved
@akdor1154
Copy link
Contributor Author

akdor1154 commented Jun 20, 2020

thanks for the response, yep I had finished at that point but will fix up your review points in a little bit.

I am a bit confused by

I don't see the user/password fields removed from the Connection struct yet?

Have I missed/misunderstood something? I preserved

Connection(dsn::AbstractString, usr, pwd) = Connection(dsn; user=usr, password=pwd)

to not break your API but as far as i can tell user and password never actually end up in the Connection struct (they are used to create the dbc from API.Connect/SQLDriverConnect I guess)

@akdor1154 akdor1154 force-pushed the remove-auth-from-dsn branch from f696c7f to 7f339f9 Compare June 22, 2020 02:45
@akdor1154 akdor1154 requested a review from quinnj June 22, 2020 03:01
Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; thanks!

@quinnj quinnj merged commit c398546 into JuliaDatabases:master Jun 29, 2020
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

Successfully merging this pull request may close these issues.

2 participants