React-admin: [RFC] Redirection to login should be done in the authProvider

Created on 4 Mar 2019  路  5Comments  路  Source: marmelab/react-admin

Problem

If the authProvider delegates login and check to a third-party server (e.g. OAuth), then it should be able to manage the login form URL.

Currently, the login form URL is hardcoded. The only possibility to redirect to an external authentication server is to use window.location in AUTH_LOGOUT, which occurs after a first redirection to '/login' in case of voluntary disconnection. That creates a blinking screen.

extract from the current auth saga:

case USER_CHECK: {
    try {
        yield call(authProvider, AUTH_CHECK, payload);
    } catch (error) {
        yield call(authProvider, AUTH_LOGOUT);
        yield put(
            replace({
                pathname: (error && error.redirectTo) || '/login',
                state: { nextPathname: meta.pathName },
            })
        );
    }
    break;
}
case USER_LOGOUT: {
    yield put(
        push(
            (action.payload && action.payload.redirectTo) ||
                '/login'
        )
    );
    yield call(authProvider, AUTH_LOGOUT);
    break;
}

Solution

The auth saga should not do the redirection by itself, but use the return object from AUTH_LOGOUT as login URL.

This is a breaking change.

breaking change enhancement

Most helpful comment

Complete Oauth (social login via Facebook/Instagram?) example will be extremely welcome!

All 5 comments

Has there been any progress on making this change?

No, as it's a breaking change, it can only occur in a major release. Development for 3.0 has just started on the next branch.

Complete Oauth (social login via Facebook/Instagram?) example will be extremely welcome!

I also recommend to add some example about authentication servers like Keycloak It's support OpenID Connect protocol.

Fixed by #3269

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alukito picture alukito  路  3Comments

marknelissen picture marknelissen  路  3Comments

yangjiamu picture yangjiamu  路  3Comments

9747749366 picture 9747749366  路  3Comments

aserrallerios picture aserrallerios  路  3Comments