2.7.2 • Published 4 years ago
@misakey/auth v2.7.2
@misakey/auth
Install
yarn add @misakey/auth
Add auth reducers
You can either: 1. import one by one the reducers you want 2. import all the reducers and combine them your way
1 - import one by one the reducers you want
In your main reducers file
import { combineReducers } from 'redux';
import auth from '@misakey/auth/store/reducers/auth';
const rootReducer = combineReducers({
auth
// ...
});
export default rootReducer;
2 - import all the reducers and combine them your way
In your main reducers file
import { combineReducers } from 'redux';
import reducers from '@misakey/auth/store/reducers';
// ...
const rootReducer = combineReducers({
...reducers,
// ...
});
export default rootReducer;
Integrate reducers and middleware
In your main app file
// Redux
import { Provider as StoreProvider } from 'react-redux';
import { applyMiddleware, compose, createStore } from 'redux';
import reducers from 'store/reducers';
// Persistence
import { PersistGate } from 'redux-persist/integration/react';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
// Middlewares
import APITokenMiddleware from '@misakey/auth/middlewares/APItoken';
// Silent auth
import {
isSilentAuthIframe,
processSilentAuthCallbackInIframe,
} from 'auth/helpers';
// OIDC provider
import OidcProvider from '@misakey/auth/components/OidcProvider';
// The main purpose of the iframe is to launch auth request and update user
// in localStorage when the request is finished. It doesn't need to load the
// rest of the application and if it does, the iframe can throw timeout errors
// https://github.com/maxmantz/redux-oidc/issues/48#issuecomment-315422236
if (isSilentAuthIframe()) {
processSilentAuthCallbackInIframe();
} else {
const middleWares = [APITokenMiddleware]; // + your other middlewares
const rootPersistConfig = {
key: 'root',
storage,
whitelist: ['global'],
blacklist: []
};
const persistedReducer = persistReducer(rootPersistConfig, reducers);
const store = createStore(
persistedReducer,
compose(applyMiddleware(...middleWares))
);
const persistor = persistStore(store);
const oidcConfig = {
authority: 'https://auth.misakey.com.local/',
client_id: '<client_id>',
redirect_uri: 'https://api.misakey.com.local/app/auth/callback',
}
ReactDOM.render((
<StoreProvider store={store}>
<OidcProvider store={store} config={oidcConfig}>
<PersistGate persistor={persistor}>
{/* ... */}
</PersistGate>
</OidcProvider>
</StoreProvider>
), document.getElementById('root'));
}
2.7.2
4 years ago
2.4.0
4 years ago
2.3.1
4 years ago
2.4.0-alpha
4 years ago
2.3.0
4 years ago
2.2.0
4 years ago
2.1.4
4 years ago
2.1.4-alpha.0
4 years ago
2.1.3
4 years ago
2.1.2
4 years ago
2.1.1
4 years ago
2.1.3-0
4 years ago
2.1.2-0
4 years ago
2.1.1-0
4 years ago
2.1.1-alpha.2
5 years ago
2.1.1-alpha.1
5 years ago
2.1.1-alpha.0
5 years ago
2.1.0
5 years ago
2.0.4
5 years ago
2.0.3
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.4.0
5 years ago
2.0.0-alpha.3
5 years ago
2.0.0-alpha.2
5 years ago
2.0.0-alpha.1
5 years ago
2.0.0-alpha.0
5 years ago
0.8.1
5 years ago
0.7.1
5 years ago
0.6.1
5 years ago
0.5.1
5 years ago
0.4.1
5 years ago
0.3.1
5 years ago
0.2.1
5 years ago
1.3.0
5 years ago
1.2.1
5 years ago
1.2.0
5 years ago
1.1.1
5 years ago
1.1.1-2
5 years ago
1.1.1-1
5 years ago
1.1.1-0
5 years ago
1.1.0
5 years ago
1.0.0
5 years ago
0.1.0
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago