#98 Convert stored Condition config options back to booleans
Merged by puiterwijk. Opened by merlinthp.
merlinthp/ipsilon master  into  master

Download 98.patch

All options types are stored as strings in the backend database. The
Condition config option type is a subclass of the Pick option that has
only the Python True and False values as valid values. When a specific
value for the option is stored into the database, this is rendered into the
text strings 'True' or 'False'. When the option is loaded back from the
database, it remains a string. This causes the issue that any "it option"
style checks will always evaluate to true. This manifests in the plugin
configuration pages, where the checkboxes for Condition options are always
checked, even if the value is set to false in the database.

This patch adds code to the Condition import_value function to coerce the
strings into Python bools.

The authfas plugin has a Condition option that it tries to use the value of
as a string, so convert that to a boolean operation.

Signed-off-by: Howard Johnson merlin@merlinthp.org

Reproducer:
* Log in
* Admin console
* Identity providers
* Configure SAML2
* Untick "allow self registration"
* Save

"Allow self registration" is ticked again. Check the backend database and see that it's set to false:

$ sqlite3 qrun/adminconfig.sqlite .dump | fgrep regist
INSERT INTO "provider_config" VALUES('saml2','allow self registration','False');

this should probably be an "elif value == 'False'", so that we still get the default behaviour if an option is unspecified.

rebased

Pull-Request has been merged by puiterwijk

Commit 0e29d12c fixes this pull-request

Metadata