Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6840475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:50:56+00:00 2026-05-26T23:50:56+00:00

Yes, I know there’s Voter tutorial in cookbook . But I’m looking for something

  • 0

Yes, I know there’s Voter tutorial in cookbook. But I’m looking for something slightly different. I need two different layers of blacklisting:

  1. deny certain IP to access whole site
  2. deny certain IP to log in

I wrote Voter that checks if user’s IP is in database. For first scenario, I wrote a kernel listener that checks every request and throws 403 in case it encounters banned user:

if (VoterInterface::ACCESS_DENIED === $this->voter->vote($token, $this, array())) {
    throw new AccessDeniedHttpException('Blacklisted, punk!');
}

First problem lies in VoterInterface itself, which forces me to use TokenInterface $token, which I don’t really need in this case. But that doesn’t matter that much I guess. Next thing is that I actually had to use AccessDeniedHttpException as AccessDeniedException always tries to redirect me to login page and causes endless redirect loop in this case. I’d live with it as it works just fine in dev environment, but when I switch to prod I keep getting 503 with following in prod log:

[2011-11-21 20:54:04] security.INFO: Populated SecurityContext with an
anonymous Token [] []

[2011-11-21 20:54:04] request.ERROR:
Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException:
Blacklisted, punk! (uncaught exception) at xxx line 28 [] []

[2011-11-21 20:54:04] request.ERROR: Exception thrown when handling an
exception
(Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException:
Blacklisted, punk!) [] []

From what I’ve read, it might be problem with xdebug, but it happens even when I turn it off. I also tried vanilla \Exception and it does the same thing. Anyone have any idea why it happens? Or maybe some other solution for such blacklisting case.

Also, I’ve no idea how to solve second case as I don’t know how to stop user before he gets token assigned. My current solution is dealing with InteractiveLoginEvent, checking if user is blacklisted and if so, removing his token. It doesn’t seem to be a safe one and I’m not really comfortable with it. So, any idea how to solve this one? I guess I’m just missing some obvious “pre login event”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:50:57+00:00Added an answer on May 26, 2026 at 11:50 pm

    To deny access to the entire website, you can adapt the whitelist code used to secure the dev environment. Stick something like this in app.php:

    if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '1.2.3.4',))) {
        header('HTTP/1.0 403 Forbidden');
        exit('You are not allowed to access this site.');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yes, I know there's AlertDialog.Builder, but I'm shocked to know how difficult (well, at
First, yes I know about this question , but I'm looking for a bit
Yes, I know there is MonoDevelop . But what if I want to use
Yes I know there has been similar posts to this however after looking through
I know there are alot of different questions about this but none of them
Yes, I know, the archive bit is evil. That being said, is there support
(Yes I know I can call Java code from Scala; but that is pointless;
Let's say I am designing a simple logging class (yes - I know there
I know there's been some questions around this topic, but the ones I'd like
I know that normally there are no problems using Git from different OSs to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.