Country access module provides the ability to add a list of countries that you wish to allow or deny access your site.
You can add country code to allow or deny access to the site such us GB,IT,US etc...
List of country codes here. Column A2
It depends on Smart IP or IP-based determination of Country
* Go to admin/config/people/country_access
* Select module you would like to use.
* Add a list of countries
* Customize your message
* Select the action to perform on the contries listed above
* Choose a page to redirect to
You also have a predefined empty template for the fallback page. You can also choose to add your own page.
Sandbox page: https://www.drupal.org/sandbox/vincenzogambino/2490172
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/VincenzoGambino/2490172.git country_access
cd country_access
Manual Reviews:
https://www.drupal.org/node/2454523#comment-9933572
https://www.drupal.org/node/2484397#comment-9933648
https://www.drupal.org/node/2486567#comment-9955735
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | d7_country_access-2490178-12.patch | 973 bytes | ayesh |
Comments
Comment #1
vincenzo gambino commentedComment #2
vincenzo gambino commentedComment #3
vincenzo gambino commentedComment #4
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxVincenzoGambino249017...
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #5
vincenzo gambino commentedFixed Parareview errors http://pareview.sh/pareview/httpgitdrupalorgsandboxvincenzogambino249017...
Comment #6
vincenzo gambino commentedComment #7
vincenzo gambino commentedComment #8
vincenzo gambino commentedComment #9
vincenzo gambino commentedComment #10
ayesh commentedHi there,
I went through your code, and this surely would be a handy module.
I'm setting this to "Needs work" because of the security issue below.
Access to the admin form. Of this module requires a permission that is defined by the module itself. Since it does not warn about potential security issues either, module must sanitize the user-provided error message. There is no such thing in the provided default template.
If you enter some malicious code in the error message in admin settings, it gets executed without a problem, who chairs, should not happen.
also, the function you use to get the country code is amend "set" where it's actually returning the country code and nothing else.
As a feature request, I would also like to see if module can support Cloudflare-provided country code. Cloudflare provides the country code in an HTTP header in the request, so you can access it without any module support.
Also, I would use the Drupal core's country_get_list() function to provide a select list for better UX (as opposed to asking user to enter country codes). Select list will provide you with an array, with no duplicates and further validation necessary.
Comment #11
vincenzo gambino commentedHi Ayesh,
thanks for your review.
I have fixed the module following your suggestion.
Comment #12
ayesh commentedWell, your solution fixes the security issue, but since the value is saved in the encoded form, it gets encoded again and again when you save the form. Try entering a denied message that has "&" character in it.
Attached patch fixes the same issue but it does not sanitize the user-entered value before saving it to the database (you shouldn't). User input is sanitized when outputting it.
Otherwise looks good to me.
Comment #13
vincenzo gambino commentedHi Ayesh,
I have applied you patch. Thanks a lot.
Can this thread now be set to Reviewed and Tested by the community?
Thanks,
Vincenzo
Comment #14
klausiPlease don't remove the security tag, we keep that for statistics and to show examples of security problems.
Comment #15
vincenzo gambino commentedHi Klausi,
sorry about that. I did not know.
Vincenzo
Comment #16
vincenzo gambino commentedComment #17
vincenzo gambino commentedComment #18
ajaynimbolkar commentedReview of the 7.x-1.x branch (commit e749f7a):
No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.
Manual Review
Individual user account
[Yes: Follows] the guidelines for individual user accounts.
No duplication
[Yes: Does not cause] module duplication and/or fragmentation.
Master Branch
[Yes: Follows] the guidelines for master branch.
Licensing
[Yes: Follows / No: Does not follow] the licensing requirements.
3rd party assets/code
[Yes: Follows ] the guidelines for 3rd party assets/code.
README.txt/README.md
[Yes: Follows] the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
[Yes: Follows] the guidelines for project length and complexity.
Secure code
[Yes: Meets the security requirements.]
Coding style & Drupal API usage
[List of identified issues in no particular order. Use (*) and (+) to indicate an issue importance. Replace the text below by the issues themselves:
t('Choose the module for IP to country detection') . '
' .
t('supported modules') . l(t('Smart IP'), 'https://www.drupal.org/project/smart_ip') . t(' or ') . l(t("IP-based Determination of a Visitor's Country"), "https://www.drupal.org/project/ip2country"),
Comment #19
ajaynimbolkar commentedComment #20
vincenzo gambino commentedHi ajayNimbolkar,
Thanks for your review,
I have fixed all the errors you spotted.
(*)variable_set('country_access_active', 0); line no 14 in ".install" file, this variable not used in .module. Please remove this variable if not required
It is supposed to be in use in .module now it has been moved in country_access.admin.inc
(*)"access_country_active" line number 92, Why you seting this variable here, you can set this variable in .install file and remove "country_access_active" variable
This was misspelled, now changed to country_access_active. The modules has an OR dependencies, if you install the module without Smart IP or IP2Country the variable will be set to 0. If you install one between those two modules, when you visit the admin page it will check the dependencies and set the variable to 1.
(*) Always create admin configuration page changes in new file such as country_access.admin.inc file so that it will be easy to handle
Done
(*) line no 56, used l() functon of drupal.As below
t('Choose the module for IP to country detection') . '
' .
t('supported modules') . l(t('Smart IP'), 'https://www.drupal.org/project/smart_ip') . t(' or ') . l(t("IP-based Determination of a Visitor's Country"), "https://www.drupal.org/project/ip2country"),
(*)Used above approach on line 69
Done
(*) Why there is need of form_alter line 110, you can used $form['#validate'][] = 'country_access_admin_form_validate'; before return system_settings_form($form); and remove the form alter code.
Done
Thanks.
Comment #21
vincenzo gambino commentedComment #22
naveenvalechaAssigning to myself for next review that will be tonight.
Comment #23
naveenvalechaReview of the 7.x-1.x branch (commit 53a2360):
Already used the pareview template above.
Manual Review :
Not found any blocker.Assigning @klausi to give it a final look
Comment #24
vincenzo gambino commentedThank you very much for your help, naveenvalecha.
Vincenzo
Comment #25
klausimanual review:
I'm not sure if the page caching access bypass qualifies as security issue, since users can work around the country access check with proxies anyway. The rest is also not critically blocking, so ...
Thanks for your contribution, Vincenzo Gambino!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #26
vincenzo gambino commentedThanks you very much, Klausi.
I will do all the fixes you suggested.
It is a pleasure to contribute back to Drupal.
Thanks again to all the people who reviewed my module @ayesh, @ajayNimbolkar, @naveenvalecha .
Vincenzo