AxaFrance / oidc-client

Light, Secure, Pure Javascript OIDC (Open ID Connect) Client. We provide also a REACT wrapper (compatible NextJS, etc.).
MIT License
597 stars 160 forks source link

No endpoint defined authentication/callback #782

Closed jmpokar closed 2 years ago

jmpokar commented 2 years ago

Issue and Steps to Reproduce

Configuration: redirect_uri: window.location.origin+"/authentication/callback", silent_redirect_uri: window.location.origin+"/authentication/silent-callback",

Code is retrieved fine but when it hits redirect_uri, call comes to server and I don't have any endpoint that handles "authentication/callback?code=.." so i get "Cannot GET /authentication/callback"

later I have added the endpoint in server/app.ts app.use('/authentication/callback', (req, res) => { res.sendFile(path.join(__dirname, '..', 'build', 'index.html')); })

but this fails the other static endpoints by changing the path to /authentication. Example: http://localhost:3000/authentication/env-config.js

I am new to OAuth and not sure where exactly authentication/callback is defined and what is the correct way i should handle this scenario? appreciate any help on this, thanks!

Note: It is React Single page application .

Versions

Using "@axa-fr/react-oidc": "5.7.2",

guillaume-chervet commented 2 years ago

Hi @jmpokar, thank you for the issue,

I have to finish a pull request for managing hash routing. https://github.com/AxaGuilDEv/react-oidc/pull/781

I think it will do what you need. I finished it as soon as i can.

jmpokar commented 2 years ago

Hi @guillaume-chervet, Thanks for quick response. I tried to set this with idp, redirect_uri: window.location.origin+"#/authentication/callback but our idp doesn't support "#" It gives error "Redirect URI must not include a fragment component."

could you please suggest some alternative/work around to this. Thanks!

guillaume-chervet commented 2 years ago

I think you need to configure well your node application. Did you tried that ? https://stackoverflow.com/questions/65312400/simple-no-frameworks-node-js-server-to-host-a-spa-react-app

guillaume-chervet commented 2 years ago

Hi @jmpokar , I have to finish a pullrequest to support "#" , do you need it quickly?

guillaume-chervet commented 2 years ago

It is working pretty well in the last version https://github.com/AxaGuilDEv/react-oidc/commit/a52d83787b64e149a0a05aa20dcb0f55a9430859

May you confirm if it is work for you?

guillaume-chervet commented 2 years ago

Hi @jmpokar , thank you for the issue. I think it is working fine now. I close the issue, feel free to reopen it if needed.