GithubHelp home page GithubHelp logo

Change callback path about bell HOT 4 OPEN

mikara89 avatar mikara89 commented on July 20, 2024
Change callback path

from bell.

Comments (4)

Nargonath avatar Nargonath commented on July 20, 2024

If I may ask, why do you want to setup a different path for the callback in the first place?

From what I understood when you query your endpoint, /login in your example, the handler of your route is only reached once the user is successfully authenticated through the third-party system. The intermediary steps are handled for you by bell. If you want to have the hand over these intermediary steps then I'm not sure there is a point to use bell then. From the docs:

bell works by adding a login endpoint and setting it to use a bell-based authentication strategy. bell will manage the third-party authentication flow and will only call the handler if the user successfully authenticated.

Source: https://hapi.dev/module/bell#usage.

As per your question, I don't think you can change to a different redirect path.

from bell.

mikara89 avatar mikara89 commented on July 20, 2024

For example, for the login endpoint I will expect some query parameters that I would like to validate and on callback endpoint I will not validate those parameters. And I don't like the idea of starting a login process and ending it (callback process) done on the same endpoint. I am using bell with "custom strategy", so I like that bell provides functionalities but if it is possible to change the callback route that would be nice.

Usage without a strategy
Sometimes, you want to use bell without using specifying a Hapi strategy. This can be the case when combining the auth logic together with another module.
bell exposes an oauth object in its plugin. Therefore, server.plugins.bell.oauth now has all that's needed. For example, calling the v2 method with all the settings documented above, will handle the oauth2 flow.

from bell.

Nargonath avatar Nargonath commented on July 20, 2024

For the checks on your query parameter, depending on the checks you want to make you could validate them directly in your route configuration through joi schemas. If you want deeper validation i.e database checks you can try using a lifecycle endpoint that happens before credentials validation/auth logic like onRequest.

As of now, I'm not sure you can separate your callback URL to the starting point URL.

from bell.

Eomm avatar Eomm commented on July 20, 2024

? As of now, I'm not sure you can separate your callback URL to the starting point URL.

I did it by setting the location as function

    const basicSettings = {
        provider: {
            protocol: 'oauth',
            profileMethod: 'post',
            signatureMethod: 'RSA-SHA1',
        },
        providerParams: false,
        allowRuntimeProviderParams: false,

        cookie: settings.cookieName,
        skipProfile: true,
        forceHttps: false,
        location (request) {
            if (request.query.oauth_verifier) {
                return request.server.info.protocol + '://' + request.info.host + '/foo';
            }
            return request.server.info.protocol + '://' + request.info.host + '/bar?xyz=' + encodeURIComponent(request.query.custom);
        },
    };

from bell.

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.