If one is to ensure something, isn't it something done by them? As far as I'm concerned, "thanks to" would go with "the government", "the constitution", etc. Or maybe the sentence would be changed a bit into something like this;
The rights of foreigners are under the protection (or aegis) of ....
... ensures that the rights of foreigners are protected by...
It is ...'s duty to ensure that the rights of foreigners are protected.
Maybe instead of feeling obliged to use the predetermined words, it'd be better to use the words that enable you to construct the very sentence that you meant in the first place.