Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cobrand hook to deny access to pages #2092

Merged
merged 1 commit into from Jun 19, 2018

Conversation

struan
Copy link
Member

@struan struan commented Apr 17, 2018

Add a check in the root controller auto to a cobrand hook that denies
access if it returns true. This goes here so that cobrands and users are
set up, which is not the case for check_login_required. Used to do
things like deny site access unless the user is a superuser.

@codecov
Copy link

codecov bot commented Apr 17, 2018

Codecov Report

Merging #2092 into master will decrease coverage by 0.6%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2092      +/-   ##
==========================================
- Coverage    78.7%   78.09%   -0.61%     
==========================================
  Files         182      178       -4     
  Lines       11738    11493     -245     
  Branches     2181     2113      -68     
==========================================
- Hits         9238     8976     -262     
- Misses       1738     1798      +60     
+ Partials      762      719      -43
Impacted Files Coverage Δ
perllib/FixMyStreet/App/Controller/Root.pm 95.38% <100%> (+0.07%) ⬆️
perllib/FixMyStreet/Cobrand/Whitelabel.pm 33.33% <0%> (-66.67%) ⬇️
perllib/FixMyStreet/Cobrand/BathNES.pm 9.21% <0%> (-36.45%) ⬇️
perllib/FixMyStreet/DB/ResultSet/Alert.pm 61.53% <0%> (-30.77%) ⬇️
perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm 68.75% <0%> (-25%) ⬇️
...rllib/FixMyStreet/DB/ResultSet/ResponseTemplate.pm 77.77% <0%> (-22.23%) ⬇️
perllib/FixMyStreet/DB/ResultSet/Comment.pm 72.72% <0%> (-18.19%) ⬇️
perllib/FixMyStreet/Script/UpdateAllReports.pm 74.21% <0%> (-15.34%) ⬇️
perllib/FixMyStreet/Cobrand/Bromley.pm 55.55% <0%> (-4.45%) ⬇️
perllib/FixMyStreet/DB/ResultSet/Problem.pm 87.62% <0%> (-3.19%) ⬇️
... and 39 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75a07fb...85ae59f. Read the comment docs.

@struan struan force-pushed the issues/commercial/1017-superuser-login-only branch 3 times, most recently from 40e1dcd to 35f5a97 Compare April 24, 2018 08:58
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of small things.

@@ -39,6 +39,7 @@ sub auto : Private {

# decide which cobrand this request should use
$c->setup_request();
$c->detach('/auth/redirect', []) if $c->cobrand->call_hook(check_login_disallowed => $c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to pass in $c here, it's available as $self->{c} in a cobrand during a web request.


$mech->get('/');
is $mech->status, 302, 'disallowed page issues a redirect';
is $mech->res->headers->header('location'), 'http://localhost/auth?r=auth', 'redirects to auth page';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirecting to /auth?r=auth doesn't feel right; if you fetched the front page, shouldn't it have been /auth?r=?

@dracos dracos added Reviewed and removed Reviewing labels Jun 18, 2018
Add a check in the root controller `auto` to a cobrand hook that denies
access if it returns true. This goes here so that cobrands and users are
set up, which is not the case for `check_login_required`. Used to do
things like deny site access unless the user is a superuser.
@struan struan force-pushed the issues/commercial/1017-superuser-login-only branch from af8dfc9 to 85ae59f Compare June 19, 2018 09:22
@struan struan merged commit 85ae59f into master Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants