jaredhanson / passport-openid

OpenID authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-openid/?utm_source=github&utm_medium=referral&utm_campaign=passport-openid&utm_content=about
MIT License
98 stars 85 forks source link

Dynamic return URL for Google #21

Open Elexy opened 11 years ago

Elexy commented 11 years ago

I am using the OpenID (google) implementation and would like to have dynamic return urls based on the request.

I'm talking about this returnUrl:

 new GoogleStrategy(
      returnURL: process.env.GOOGLE_RETURN_URL or "http://localhost:3333/auth/google/return"
      realm: process.env.GOOGLE_REALM or "http://localhost:3333/"
    , (identifier, profile, done) ->
      userRepository.findOrCreateOauthUser "google", identifier, profile, (user) ->    
        done null, user
    )

I can take the one from env, but I want the hostname+port from the request, because we have multiple hostnames pointing to the IP.

Can it be done with the current passport version?

mathieumg commented 10 years ago

I would love to see @jfaissolle 's change merged in! :)

shawnzhu commented 10 years ago

I don't think you can make the domain name part of returnURL option of an OpenID RP dynamic because returnURL is a fixed URL on the RP side and this value will be set once only.

There's one commit on my fork of node-openid, it added query string to returnURL which means only the query string can change. for example:

lazychino commented 10 years ago

After checking the code, my solution would be give returnURL the path for returning (example: "/auth/google/return") and have authenticate() get the hostname on each request from req.headers.host.

@jfaissolle I didn't saw yours that's a nice solution :+1: we need that PR

ValentinFunk commented 10 years ago

Any news on this? Is there any problem with @jfaissolle's solution?

men232 commented 8 years ago

+1

ghost commented 8 years ago

Would love to be able to pass a custom callbackURL via openid.

:+1: