Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /login-callback route and optional new authProvider.handleLoginCalback() method #8457

Merged
merged 23 commits into from
Dec 12, 2022

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Dec 1, 2022

Problem

When using third party services such as Auth0, you currently need to setup a custom route and work around the authProvider methods.

Solution

Introduce a new route at /login-callback that can be set as the callback endpoint for third party authentication services. This route will call the new handleCallback optional method of the AuthProvider then redirect to the home page by default.

Tasks

  • Implementation
  • Documentation

…nCalback` method

## Problem

When using third party services such as Auth0, you currently need to setup a custom route and work around the authProvider methods.

## Solution

Introduce a new route at `/login-callback` that can be set as the callback endpoint for third party authentication services. This route will call the new `handleLoginCallback` optional method of the `AuthProvider` then redirect to the home page by default.
Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encouraging!

docs/Authentication.md Outdated Show resolved Hide resolved
docs/Authentication.md Outdated Show resolved Hide resolved
When using external authentication services such as those implementing OAuth, you usually need a callback route. React-admin provides a default one at `/login-callback`. It will call the `AuthProvider.handleLoginCallback` method
that may validate the params received from the URL and redirect users to any page (the home page by default) afterwards.

It's up to you to decide when to redirect users to the third party authentication service, for instance:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing. Could you elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get what's confusing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this section occurs here. It has nothing to do with the login callback

Copy link
Contributor Author

@djhi djhi Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I introduce a new dedicated page to third party authentication services ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least a section in the Authentication introduction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the authentication introduction page

packages/ra-core/src/auth/useHandleLoginCallback.spec.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/auth/useHandleLoginCallback.ts Outdated Show resolved Hide resolved
packages/ra-core/src/auth/useHandleLoginCallback.ts Outdated Show resolved Hide resolved
packages/ra-core/src/auth/useHandleLoginCallback.ts Outdated Show resolved Hide resolved
packages/ra-core/src/types.ts Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/AdminUI.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/auth/useHandleLoginCallback.spec.tsx Outdated Show resolved Hide resolved
docs/Admin.md Outdated Show resolved Hide resolved
docs/Admin.md Outdated Show resolved Hide resolved
@vercel
Copy link

vercel bot commented Dec 6, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-admin-storybook ✅ Ready (Inspect) Visit Preview Dec 7, 2022 at 10:20AM (UTC)
1 Ignored Deployment
Name Status Preview Updated
react-admin ⬜️ Ignored (Inspect) Dec 7, 2022 at 10:20AM (UTC)

cypress/e2e/permissions.cy.js Outdated Show resolved Hide resolved
docs/Admin.md Outdated Show resolved Hide resolved
When using external authentication services such as those implementing OAuth, you usually need a callback route. React-admin provides a default one at `/login-callback`. It will call the `AuthProvider.handleLoginCallback` method
that may validate the params received from the URL and redirect users to any page (the home page by default) afterwards.

It's up to you to decide when to redirect users to the third party authentication service, for instance:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this section occurs here. It has nothing to do with the login callback

docs/Authentication.md Outdated Show resolved Hide resolved
packages/ra-core/src/auth/index.ts Show resolved Hide resolved
packages/ra-core/src/auth/useHandleAuthCallback.spec.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/types.ts Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/AuthError.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/LoginCallback.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/auth/index.ts Outdated Show resolved Hide resolved
@fzaninotto fzaninotto merged commit e54d433 into next Dec 12, 2022
@fzaninotto fzaninotto deleted the login-callback branch December 12, 2022 14:04
@fzaninotto
Copy link
Member

Awesome!

@fzaninotto fzaninotto added this to the 4.7.0 milestone Dec 12, 2022
fzaninotto added a commit that referenced this pull request Dec 12, 2022
Seojun-Park pushed a commit to Seojun-Park/react-admin that referenced this pull request Dec 19, 2022
Seojun-Park pushed a commit to Seojun-Park/react-admin that referenced this pull request Dec 19, 2022
Seojun-Park pushed a commit to Seojun-Park/react-admin that referenced this pull request Dec 19, 2022
Seojun-Park pushed a commit to Seojun-Park/react-admin that referenced this pull request Dec 19, 2022
@fzaninotto fzaninotto changed the title Add login-callback hook and authProvider optional new handleLoginCalback method Add /login-callback route and optional new authProvider.handleLoginCalback() method Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants