Fix #87: security helper converted into component and improved

Fix #87: security helper improvement

Migrated from #4052
https://github.com/yiisoft/yii2/commit/deecdcad842aeeeeb8d8b0417adbfc802c2f0ce6