Giter Site home page Giter Site logo

Comments (13)

rochamarcelo avatar rochamarcelo commented on June 3, 2024

Please check https://github.com/CakeDC/auth/blob/3.next/Docs/Documentation/ApiKeyAuthenticate.md

from auth.

rochamarcelo avatar rochamarcelo commented on June 3, 2024

You could try using header instead of querystring

$config['Auth']['authenticate']['CakeDC/Users.ApiKey'] = [
    'type' => 'header',
    ];

from auth.

rrd108 avatar rrd108 commented on June 3, 2024

@rochamarcelo I know how to set up to accept the ApiKey in the header. My problem is that the first OPTIONS preflight request does not contain the ApiKey header, so the request is redirected.

So what I would need is allowing OPTIONS requests to the application without the ApiKey.

from auth.

rochamarcelo avatar rochamarcelo commented on June 3, 2024

It seems that you need a custom authorization rule for it, I'm not sure if this is a generic case.

from auth.

rrd108 avatar rrd108 commented on June 3, 2024

Can you give me a hint how to do that?

from auth.

rochamarcelo avatar rochamarcelo commented on June 3, 2024

@rrd108 please try to add a CorsMiddleware like this one https://github.com/ozee31/cakephp-cors/blob/master/src/Routing/Middleware/CorsMiddleware.php

This should handle the OPTIONS request without having to add custom authorization rules.

Please let us know if this works for you.

from auth.

rrd108 avatar rrd108 commented on June 3, 2024

As I see there is official support for this. Am I right?

https://book.cakephp.org/3/en/controllers/request-response.html#setting-cross-origin-request-headers-cors

Addind OPTIONS to allowMethods did not helped

from auth.

rochamarcelo avatar rochamarcelo commented on June 3, 2024

It seems similar to how the mentioned middleware works, but instead of using named methods like allowHeaders it uses withHeader method

from auth.

rrd108 avatar rrd108 commented on June 3, 2024

hm... it still refuses option requests

from auth.

rochamarcelo avatar rochamarcelo commented on June 3, 2024

Have you followed the plugin installation steps, it requires some config keys https://github.com/ozee31/cakephp-cors#configuration

from auth.

rrd108 avatar rrd108 commented on June 3, 2024

the problem is that options request does not contain the apikey, so they are refused by the plugin

from auth.

rochamarcelo avatar rochamarcelo commented on June 3, 2024

@rrd108 if you check the mentioned behavior, the response for OPTIONS request is handled at https://github.com/ozee31/cakephp-cors/blob/master/src/Routing/Middleware/CorsMiddleware.php#L23

So, using that behavior the OPTIONS requestt will not go to controller layer but just return a simple response. If you tried to use that behavior and did not worked please debug the IF conditions.

from auth.

steinkel avatar steinkel commented on June 3, 2024

closing this one, if the issue persists please reopen

from auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.