Skip to content

#[DisableCsrfChecks()] no longer works #21414

Description

@DonutsNL

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Version

11.0.1

Bug description

Im trying to adopt the samlsso (glpisaml) plugin to the latest version of GLPI. While working with the GLPI11 beta release i was able tot disable the Csrf checking by adding the decorator: #[DisableCsrfChecks()] in the plugins controller. The code looks like:

####################################################################
    use Symfony\Component\HttpFoundation\Request;                           // Required for __invoke
    use Symfony\Component\HttpFoundation\Response;                          // Required for __invoke
    use Symfony\Component\Routing\Attribute\Route; 

   #[ ... ] 


    // SLO route
    public const SLO_ROUTE      = 'front/slo';                                  // Route being registered by __class__
    public const SLO_NAME       = 'samlsso_SLO';                            // Route name

    #[SecurityStrategy(Firewall::STRATEGY_NO_CHECK)]                  // Decorator to disable authentication check
    #[Route(self::SLO_ROUTE, name: self::SLO_NAME)]                    // Decorator to register route
    #[DisableCsrfChecks()]                                                                // Decorator to disable Csrf checking
    public function slo(Request $request): Response                       // What to do if route is invoked.
    {
        global $CFG_GLPI;
        return new Response('', 307, ['location' => $CFG_GLPI['url_base'].'/']);    // Redirect back to application root.
    }

With the glpi11 release this isnt working anymore. The csrf check is applied on external IdP SamlResponses resulting in an not allowed error.

I noticed GLPI uses the 'security_level: 0' param in its own routes but this doesnt seem to be implemented via the Symphony Route Attribute that the plugin uses.

Long story short, what would be the current 'correct' way to disable CsrfChecks on a specific plugin routes?

Thanks in advance.

Relevant log output

Page URL

No response

Steps To reproduce

Code snippet results in CsrfCheck failed error on plugin endpoint.

Your GLPI setup information

Glpi 11.0.1 running in Ubuntu, Apache2, PHP8.4-Fpm,Mysql.

Anything else?

Headers are shown on top of plugin screens in the GLPI UI:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions