diefferson / http_certificate_pinning

Https Certificate pinning for Flutter
Apache License 2.0
84 stars 71 forks source link

Replace options.baseUrl with options.uri? #4

Closed devfelipereis closed 3 years ago

devfelipereis commented 3 years ago

Hello.

Sometimes we can make requests for some apis that is not using the base url and pass the full url to dio. Ex: baseUrl = https://google.com.br/api/ a request outside the baseUrl: https://twitter.com/api/

When doing this, the interceptor will only validates the baseUrl and let the others pass.

Using options.uri will check for the url that is being requested.

What do you think?

Thank you!

EDIT: Pull request https://github.com/diefferson/http_certificate_pinning/pull/5

EDIT 2:

We could also check for origin. In the twitter example, we will get only https://twitter.com

diefferson commented 3 years ago

Hello, @devfelipereis, I understand your opinion, but what do you think in create two Dio Clients? I like this approach in my projects. You can resolve the client using Dependence Injection for example.

And you need to pinning all certificates to works different endpoints in the same app. This is interesting if both of endpoints belongs to you.

devfelipereis commented 3 years ago

Yeah... seens to be better and we can have more control, diferrent configs for each client. Thank you!