Giter VIP home page Giter VIP logo

Comments (10)

markstory avatar markstory commented on May 14, 2024

I think you would have to compare array values as well.

from authentication.

burzum avatar burzum commented on May 14, 2024

@markstory exactly my thought but then it is required that you run the routing middleware before authentication. But this brings up a problem if we want to do authorization against routes. authorization requires the identity.

from authentication.

markstory avatar markstory commented on May 14, 2024

Couldn't the 'loginAction' be defined as a string URL if people have multiple possible routes a login page can be reached at?

from authentication.

burzum avatar burzum commented on May 14, 2024

We would always require a string then and turn the URI from the request also into an array and then compare them. Or am I missing something? If not I'll do the change.

from authentication.

markstory avatar markstory commented on May 14, 2024

That sounds like it should work to me.

from authentication.

burzum avatar burzum commented on May 14, 2024

@markstory does that look OK?

    protected function _checkLoginUrl(ServerRequestInterface $request)
    {
        $loginUrl = $this->getConfig('loginUrl');

        if (!empty($loginUrl)) {
            $requestUrl = Router::parseRequest($request);

            if (is_string($loginUrl)) {
                $loginUrl = Router::parseRequest((new ServerRequest([
                    'uri' => $loginUrl
                ])));
                $this->setConfig('loginUrl', $loginUrl);
            }

            $keysToCompare = array_keys($loginUrl);

            foreach ($keysToCompare as $key) {
                if (!array_key_exists($key, $requestUrl)
                    || $requestUrl[$key] !== $loginUrl[$key]
                ) {
                    return false;
                }
            }

        }

        return true;
    }

from authentication.

markstory avatar markstory commented on May 14, 2024

You could use Hash::diff or array_key_diff() to check the difference between the two URL arrays.

from authentication.

burzum avatar burzum commented on May 14, 2024

@markstory I've pushed the code to the branch bug/check-login-url there is an issue with the routing it seems, I'm not sure if we simply want to match against the URL it has generated in this case. Would you mind to look at the code?

from authentication.

markstory avatar markstory commented on May 14, 2024

Sure, I'll try to take a look in the next few days.

from authentication.

markstory avatar markstory commented on May 14, 2024

Closing as #146 covers this.

from authentication.

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.