Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
redux-oauth
Advanced tools
Bearer token-based authentication library with omniauth support for redux applications
First version is based and fully compatible with Redux-Auth. Support is discontinued.
Second version is more simple to configure and more stable. All React Components were also extracted to separate packages, therefore React is removed from dependencies.
Configuration is required only on server-side. Client will fetch configuration and latest authentication data from redux initial state.
Dispatch fetch action with any Url and fetch API options. If it is an API request, than authentication headers are applied prior the request and token value in redux store and browser cookies is updated right after. Otherwise, regular request is performed.
Provide request cookies for initial authentication information. Optional
Provide current url. MANDATORY to process OAuth callbacks properly.
apiUrl - MANDATORY, base url to your API
tokenValidationPath - path to validate token, default: /auth/validate_token
signOutPath - path to sign out from backend, default: /auth/sign_out
authProviderPaths - configuration for OAuth2 providers, default: {}
key - cookie key for storing authentication headers for persistence, default: 'authHeaders'
path - cookie path, default: '/'
expire - cookie expiration in days, default: 14
authentication data structure, which is going back and forth between backend and client
Access-Token - no default value
Token-Type - default value: 'Bearer',
Client - no default value
Expiry - no default value
Uid - no default value
Authorization - default value: '{{ Token-Type } { Access-Token }}'. This expression means that default value is computed using current 'Token-Type' and 'Access-Token' values.
Unlike 'backend' and 'cookieOptions' objects if you would like to override tokenFormat, you have to provide whole structure.
import { initialize, authStateReducer } from "redux-auth";
// ...
const rootReducer = combineReducers({
auth: authStateReducer,
// ... add your own reducers here
});
app.use((req, res) => {
const store = createStore(rootReducer, {}, applyMiddleware(thunk));
store.dispatch(initialize({
backend: {
apiUrl: 'https://my-super-api.zone',
authProviderPaths: {
facebook: '/auth/facebook',
github: '/auth/github'
}
},
currentLocation: request.url,
cookies: request.cookies
}).then(() => {
// ... do your regular things like routing and rendering
// We need to update browser headers. User will still have valid session in case javascript fails
// 'authHeaders' is default cookieOptions.key value bere. If you redefined it, use your value instead
res.cookie('authHeaders', JSON.stringify(getHeaders(store.getState())), { maxAge: ... });
})
}
I wanted to make library as light-weight as possible. Also many folks have very different use-cases so it is hard to satisfy everyone. Therefore it is considered that everyone can easily implement methods they need themselves.
import { fetch, authenticateStart, authenticateComplete, authenticateError, parseResponse } from 'redux-oauth';
function signIn(email, password) {
return dispatch => {
dispatch(authenticateStart());
return dispatch(fetch(yourCustomAuthMethod(email, password)))
.then(parseResponse)
.then(user => {
dispatch(authenticateComplete(user));
// it is recommended to return resolve or reject for server side rendering case.
// It helps to know then all requests are finished and rendering can be performed
return Promise.resolve(user);
}
.catch(error => {
if (error.errors) {
dispatch(authenticateError(error.errors));
}
return Promise.reject(error.errors || error);
};
};
}
MIT (c) Yuri Dymov
FAQs
Bearer token-based authentication system for redux with OAuth2 support
The npm package redux-oauth receives a total of 9 weekly downloads. As such, redux-oauth popularity was classified as not popular.
We found that redux-oauth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.