简体   繁体   中英

Unexpected character “@” around position

I would like to create white list ips, that can connect to my api. Try to use Expression Language Component
But when I try add rule to security.yml

    - path: ^/v2/api
      allow_if: "request.getClientIp() in @=service('app.white_list_manager').getWhiteList()"

I have an error:

SyntaxError in Lexer.php line 90: Unexpected character "@" around position 25 for expression request.getClientIp() in @=service('app.white_list_manager').getWhiteList().

How I can solve it?
Symfony version 3.0.9

One workaround would be :

to simple define a listener that listens to kernel.request , inject your "@app.white_list_manager" and the "@request_stack" .

Then check what route you are on, and check the ip in the whitelistmanager, and act accordingly. (redirect, deny access, whatever)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM