
Security News
Inside Lodash’s Security Reset and Maintenance Reboot
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.
@rubriclab/auth
Advanced tools
An agent-native, type-safe authorization and authentication library for Next.js applications.
By separating notions of authentication ("who am I?") and authorization ("what can I do?"), we can scale apps to dozens of integrations while maintaining a simple, type-safe API.
bun add @rubriclab/auth
Choose between Prisma or Drizzle:
// Using Prisma
import { prismaAdapter } from '@rubriclab/auth/providers/prisma'
import { PrismaClient } from '@prisma/client'
import { env } from '@/env'
const prisma = new PrismaClient()
const databaseProvider = prismaAdapter(prisma)
// OR using Drizzle
import { drizzleAdapter } from '@rubriclab/auth/providers/drizzle'
import { drizzle } from 'drizzle-orm/neon-serverless'
const db = drizzle(env.DATABASE_URL)
const databaseProvider = drizzleAdapter(db)
import { createAuth } from '@rubriclab/auth'
import { createGithubAuthenticationProvider } from '@rubriclab/auth/providers/github'
import { createGoogleAuthenticationProvider } from '@rubriclab/auth/providers/google'
import { createResendMagicLinkAuthenticationProvider } from '@rubriclab/auth/providers/resend'
export const { routes, actions } = createAuth({
databaseProvider,
authUrl: env.NEXT_PUBLIC_AUTH_URL, // e.g., 'https://yourdomain.com'
// OAuth2 Authentication Providers
oAuth2AuthenticationProviders: {
github: createGithubAuthenticationProvider({
githubClientId: env.GITHUB_CLIENT_ID,
githubClientSecret: env.GITHUB_CLIENT_SECRET,
}),
google: createGoogleAuthenticationProvider({
googleClientId: env.GOOGLE_CLIENT_ID,
googleClientSecret: env.GOOGLE_CLIENT_SECRET,
}),
},
// Magic Link Authentication Providers
magicLinkAuthenticationProviders: {
resend: createResendMagicLinkAuthenticationProvider({
resendApiKey: env.RESEND_API_KEY,
fromEmail: 'noreply@yourdomain.com',
subject: 'Sign in to Your App',
html: (url) => `
<h1>Welcome to Your App</h1>
<p>Click the link below to sign in:</p>
<a href="${url}">Sign In</a>
`,
}),
},
})
Create an API route handler for authentication:
// app/api/auth/[...auth]/route.ts
import { routes } from '@/lib/auth'
export const { GET } = routes
// Server Component
import { actions } from '@/lib/auth'
export default async function DashboardPage() {
const session = await actions.getSession({
redirectUnauthorized: '/login'
})
return (
<div>
<h1>Welcome, {session.user.email}!</h1>
{/* Your dashboard content */}
</div>
)
}
// Client Component
'use client'
import { CreateAuthContext } from '@rubriclab/auth/client'
const { ClientAuthProvider, useSession } = CreateAuthContext<typeof session>()
export function DashboardClient({ session }: { session: typeof session }) {
return (
<ClientAuthProvider session={session}>
<DashboardContent />
</ClientAuthProvider>
)
}
function DashboardContent() {
const session = useSession()
return (
<div>
<h2>Connected Accounts:</h2>
<ul>
{session.user.oAuth2AuthenticationAccounts.map(account => (
<li key={account.accountId}>{account.provider}</li>
))}
</ul>
</div>
)
}
import { actions } from '@/lib/auth'
const { signIn, sendMagicLink, signOut } = actions
// Sign in with OAuth2
await signIn({
provider: 'github',
callbackUrl: '/dashboard'
})
// Send magic link
await sendMagicLink({
provider: 'resend',
email: 'user@example.com'
})
// Sign out
await signOut({ redirect: '/' })
# Your application's base URL for auth callbacks
NEXT_PUBLIC_AUTH_URL=https://yourdomain.com
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
RESEND_API_KEY=your_resend_api_key
GitHub (@rubriclab/auth/providers/github)
read:user, user:email (default)Google (@rubriclab/auth/providers/google)
userinfo.email, userinfo.profile (default)@rubriclab/auth/providers/resend)
GitHub (@rubriclab/auth/providers/github)
repo, admin:org, workflow, packages, etc.Google (@rubriclab/auth/providers/google)
gmail.readonly, drive.file, calendar.events, etc.Brex (@rubriclab/auth/providers/brex)
Vercel (@rubriclab/auth/providers/vercel)
Prisma (@rubriclab/auth/providers/prisma)
Drizzle (@rubriclab/auth/providers/drizzle)
The library requires the following database tables:
users - User accountssessions - User sessionsoauth2_authentication_requests - OAuth2 authentication flow stateoauth2_authorization_requests - OAuth2 authorization flow statemagic_link_requests - Magic link authentication stateoauth2_authentication_accounts - Connected OAuth2 authentication accountsoauth2_authorization_accounts - Connected OAuth2 authorization accountsapi_key_authorization_accounts - Connected API key authorization accountsimport { createOauth2AuthenticationProvider } from '@rubriclab/auth'
const customProvider = createOauth2AuthenticationProvider({
getAuthenticationUrl: async ({ redirectUri, state }) => {
const url = new URL('https://your-provider.com/oauth/authorize')
url.searchParams.set('client_id', process.env.CUSTOM_CLIENT_ID!)
url.searchParams.set('redirect_uri', redirectUri)
url.searchParams.set('state', state)
url.searchParams.set('scope', 'read:user')
return url
},
getToken: async ({ code, redirectUri }) => {
// Implement token exchange
return {
accessToken: 'token',
refreshToken: 'refresh',
expiresAt: new Date(Date.now() + 3600000)
}
},
getUser: async ({ accessToken }) => {
// Implement user info retrieval
return {
accountId: 'user_id',
email: 'user@example.com'
}
},
refreshToken: async ({ refreshToken }) => {
// Implement token refresh
return {
accessToken: 'new_token',
refreshToken: 'new_refresh',
expiresAt: new Date(Date.now() + 3600000)
}
}
})
The library provides full TypeScript support with strict typing:
// Session type inference
const session = await auth.actions.getSession({ redirectUnauthorized: '/login' })
// session.user.email is typed as string
// session.user.oAuth2AuthenticationAccounts is typed as array
// Provider type safety
await auth.actions.signIn({
provider: 'github', // TypeScript will ensure this is a valid provider
callbackUrl: '/dashboard'
})
FAQs
Unknown package
The npm package @rubriclab/auth receives a total of 3 weekly downloads. As such, @rubriclab/auth popularity was classified as not popular.
We found that @rubriclab/auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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.

Security News
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.

Security News
n8n led JavaScript Rising Stars 2025 by a wide margin, with workflow platforms seeing the largest growth across categories.

Security News
The U.S. government is rolling back software supply chain mandates, shifting from mandatory SBOMs and attestations to a risk-based approach.