
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
croods-auth
Advanced tools
Croods-auth is another layer of abstraction on top of Croods, providing you with a ready-to-use solution for user authentication and permission control.
yarn add croods-auth croods react react-dom lodash react-use-form-state
Bellow is a simple example of its usage with @reach/router:
import { CroodsProvider } from 'croods'
import { Auth, authHeaders, saveHeaders } from 'croods-auth'
export default props => (
<CroodsProvider handleResponseHeaders={saveHeaders} headers={authHeaders} baseUrl="https://foo.bar">
<Router>
<Auth
Component={SomeBlockedPage}
path="/"
unauthorized={() => redirect('/sign-in')}
/>
<SignIn path="/sign-in" />
</Router>
</CroodsProvider>
)
Main concepts to notice here:
And then we implement our SignIn page:
import { useSignIn } from 'croods-auth'
const Input = ({ name, label = name, ...props }) => (
<div className="form-group">
<label htmlFor={name}>{label}</label>
<input {...props} className="form-control" id={name} />
</div>
)
export default props => {
const [{ signingIn, error, ...config }] = useSignIn({
afterSuccess: () => navigate(`/home`),
})
return (
<form {...config.formProps}>
<h2>Sign In</h2>
<Input {...config.emailProps} label="Email address" />
<Input {...config.passwordProps} />
<button type="submit" className="btn btn-primary">
{signingIn ? 'Signing in...' : 'Sign in'}
</button>
</form>
)
}
There are hooks available for all usual authentication operations (sign up, edit profile, etc).
Read more about it on the Docs!
FAQs
Authentication made easy with Croods
We found that croods-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.