KonnexionsGmbH / OraLixir

Oracle driver for Elixir
Other
2 stars 4 forks source link

Hard coded DB Connection credentials #11

Closed cruzfarfan closed 4 years ago

cruzfarfan commented 4 years ago

I had issues connecting with the hardcoded "regit" password. Shouldn't the values be in a configuration file?

defp create_context_connection(ora, opts) do
  username = Keyword.get(opts, :username, "scott")
  password = Keyword.get(opts, :password, "regit")

...

c-bik commented 4 years ago

Hi @cruzfarfan,

I meant for password = Keyword.get(opts, :password, "regit") to supply a default if not provided! (in commit above I now changed it to "tiger", missed it last time).

All / any start parameters are overridable! For example:

iex> {:ok, pid} = OraLixir.start_link([])

uses the following defaults https://github.com/c-bik/OraLixir/blob/3ae65b2a58d4ff2040ad643fdcf17cec0fc8227c/lib/oralixir.ex#L21-L27 Now if you like to use a different password than default "tiger" you can pass it on as follows:

iex> {:ok, pid} = OraLixir.start_link([password: "something_else"])

This should only override the password while using defaults for ip, port etc.

I thought to provide some default for the options would make it simpler to write tests while still being user friendly through override!

Does that make sense? Is there a better way to do this?

cruzfarfan commented 4 years ago

Hi @c-bik ,

Yes, providing defaults is definitely a good thing, but in Elixir/Ecto those normally live in a script in the config directory. For example, the last section of a dev.exs file for an Ecto project using postgres looks like this:

Configure your database

config :mosaic, Mosaic.Repo, username: "postgres", password: "postgres", database: "mosaic_dev", hostname: "localhost", pool_size: 10

cruzfarfan commented 4 years ago

Actually, those files are used to create different configs for different environments. I'll see if I can find out what other drivers do.

Thank you