Skip to content

feat: Add makeMaybe method to SslContextModule #183

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

Merged
merged 1 commit into from
Mar 19, 2020

Conversation

jakubjanecek
Copy link
Collaborator

It is sometimes necessary to turn off the initialization of SSL context to actually turn off SSL functionality of some library (e.g. for testing). This method makes it more simple by having an enabled flag in the configuration.

@jakubjanecek jakubjanecek self-assigned this Mar 19, 2020
@jakubjanecek jakubjanecek added the feature New feature or request label Mar 19, 2020
Copy link
Contributor

@sideeffffect sideeffffect left a comment

Choose a reason for hiding this comment

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

The potentially problematic aspect of this solution is that if the caller uses make, it will always create an SSLContext (right?), even if enabled is set to false in configuration.

That's quite surprising and probably not what we want. Any suggestions how to remedy that?

We could throw in make if enabled is false 🤷‍♂️

Copy link
Contributor

@hanny24 hanny24 left a comment

Choose a reason for hiding this comment

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

Shouldn't you update reference.conf as well?

@mergify mergify bot merged commit 6ac04d5 into master Mar 19, 2020
@mergify mergify bot deleted the feat/ssl-context-make-maybe branch March 19, 2020 11:02
@sideeffffect
Copy link
Contributor

huh, the bot is really happy with merging stuff 😄
so what do you say @jakubjanecek
shouldn't we somehow remedy the issue I pointed out above before we cut a release?

@jakubjanecek
Copy link
Collaborator Author

@hanny24 I could add it but I see it as an extra feature not everyone needs. reference.conf is for the reference values of the ssl-config library and I made the decision to add an extra enabled flag there just for this method - it's kind of "virtual".

@sideeffffect Related to the think I say above, I don't want make to throw, there's no need for that, it always creates the context. The enabled flag is there just for this specific method and that's also why it's not in reference.conf.

I agree this is a small hack but it seems to me that it's not really harmful but can be very useful - I have the use case that's why I am adding it.

@jakubjanecek
Copy link
Collaborator Author

Of course we can revert this or update accordingly, the merge was premature - it's configured that once you have an approval you can merge. You shouldn't approve if you have doubts about anything.

@sideeffffect
Copy link
Contributor

I don't want make to throw

it wouldn't be nice, but isn't it better to have at least some "safety" guarantee?
other option is to rename make -> makeAlways and makeMaybe to make -- but that's breaking compatibility, so probably not worth doing that
personally, I'm not sure what would be the best thing -- this PR is a hack, but creating an SSLContext if you don't want is quite less of a mistake than the opposite 🤷‍♂️

could others chime in? @tomasherman @jendakol @augi

@hanny24
Copy link
Contributor

hanny24 commented Mar 19, 2020

But you have just broken backwards compatibility.

@jakubjanecek
Copy link
Collaborator Author

@hanny24 How did I break it? Method make behaves exactly like it used to behave and it does not consider enabled at all (on purpose).

@sideeffffect Yep, that would be possible. I wouldn't worry about breaking compatibility right now because we are still not fully released. The point is that I think most people will use make and won't even know about enabled flag at all. Those who need it can use makeMaybe and they have to provide the enabled flag (which is not part of the standard ssl-config configuration) - nothing more.

@hanny24
Copy link
Contributor

hanny24 commented Mar 19, 2020

Ahh, sorry I thought it was changed method, not added.

@augi
Copy link
Member

augi commented Mar 19, 2020

Breaking backward compatibility is not an issue IMHO if the change is important:

  1. We are on 0.x versions.
  2. We can increase the version accordingly.

@sideeffffect
Copy link
Contributor

After thinking about this for a bit, I realized that the aspect of this PR that was bothering me was that the SSLContext is enabled by default, and you have to explicitly opt out of it, but you do that by using variable enabled (which you set to false). (The fact that it's called enabled is the important part.)

In general, I think there should be a rule that config variables should not be negatives, it makes for clearer reading, but maybe this case would be an exception from the rule.
How about naming the field disabled, and the methods make: F[SSLContext] and makeUnlessDisabled: F[Option[SSLContext]]?

the name ...UnlessDisabled hint at the fact that you would have to go out of your and disable it explicitly and you do that with a variable named disabled.

@sideeffffect
Copy link
Contributor

Another option would be to backpedal on this PR, and resolve the problem @jakubjanecek described differently, possibly in (test I presume) code.
Since we're doing inversion of control (is that how it's called?), where we pass dependencies as arguments, it should be fairly easy -- at least in theory.

Or keep like it is... no biggie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

Successfully merging this pull request may close these issues.

5 participants