fix(PluginManager): AllowBridgeAccess default policy to handle scheme & hostname #1332
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
fixes: #1328
fixes: apache/cordova-plugin-device#118
Description
Update how the PluginManager handles the default policy.
AndroidInsecureFileModeEnabled
istrue
, then the default policy isfile://
AndroidInsecureFileModeEnabled
isfalse
, then the default policy is the combination of thescheme
&hostname
.https
localhost
Testing
scheme
tohttp
hostname
toapache.org
AndroidInsecureFileModeEnabled
totrue
Additional Notes
I also tested a solution that added the fix to the
AllowListPlugin
class. fa5b228This is where @NiklasMerz originally the code. The issue is that is was written in the config parser step. The config parser has not fully parse everything, e.g. the preferences, and therefore always picked the default values.
If we wanted to keep the login inside the
AllowListPlugin
file, we would have to move it to thepluginInitialize
method, after the config parser has been completed.The question really comes down to, where it should reside?
PluginManager
, is where the default policy is defined.AllowListPlugin
is where we parse the user's custom-definedallow-navigation
,allow-intent
,access
, andcontent
.IMO the
PluginManager
sounded better. Previously the default policy wasfile://
but sinceWebViewAssetLoader
was added and default should now behttps://localhost
. But also, since users can change the launch URL to either file or default/custom scheme+hostname, it seems maybe the default policy should be a bit flexible.Checklist