
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
@tailor-platform/oidc-client
Advanced tools
This package provides ways to handle Tailor authentication
This package provides ways to handle Tailor authentication
Create configuration in somewhere in your app:
import { Config } from "@tailor-platform/oidc-client";
export const config = new Config({
apiHost: "http://yourapp.mini.tailor.tech:8000",
appHost: "http://localhost:3000",
});
Each of these properties in config to specific environment variables or constants you need to define in your application's environment. Collectively, they form the configuration necessary for the client to handle user authentication in a standardized manner.
| Name | Required | Description | Default |
|---|---|---|---|
| apiHost | Yes | Tailor Platform host | |
| appHost | Yes | Frontend app host | |
| loginPath | Path the auth provider will redirect the user to after signing in | /auth/login | |
| unauthorizedPath | Path to be redirected if not authorized | /unauthorized | |
| loginCallbackPath | Auth service login endpoint | /login/callback | |
| tokenPath | Auth service token endpoint | /auth/token | |
| refreshTokenPath | Auth service refresh token endpoint | /auth/token/refresh | |
| userInfoPath | Auth service endpoint to fetch basic user information | /auth/userinfo |
Use the TailorAuthProvider component to wrap your application layouts/pages, for instance:
import { TailorAuthProvider } from "@tailor-platform/oidc-client";
import { config } from "@/libs/authConfig";
export const Providers = ({ children }: { children: ReactNode }) => (
<TailorAuthProvider config={config}>{children}</TailorAuthProvider>
);
withAuth middleware for Next.jsA middleware that mainly intercepts requests to login callback.
This middlware is required to be used in your app to use the hooks introduced later.
import { withAuth } from "@tailor-platform/oidc-client/server";
import { config as authConfig } from "@/libs/authConfig";
const middleware: unknown = withAuth(
authConfig,
{
prepend: ({ token }) => {
// Do something you want with token here
// (eg. fetch user profile and store it in LocalStorage, ...)
},
onError: (e: Error) => {
// Handle an error in authorization callback here
// Use `NextResponse.redirect` to redirect your own error page or somewhere.
},
},
(request, event) => {
// Add middlewares here if you want to chain more of them
},
);
export default middleware;
useSession hookA hook to get token in client components.
"use client";
import { useSession } from "@tailor-platform/oidc-client";
const Page = () => {
const session = useSession({
// Enabling login guard will redirect you to the path specified in `authorizedPath` in config if not authorized
required: true,
});
return <div>Token: {session.token}</div>;
};
useAuth hookA hook that provides authorization functionality. It includes:
login: A function to redirect to login URL.refreshToken: A function to refresh your token.Here is an example of how to use these functions:
"use client";
import { useAuth } from "@tailor-platform/oidc-client";
// Redirect to `/dashboard` after logging in
const Component = async () => {
const { login } = useAuth();
return (
<div>
<button
onClick={() => {
login({
redirectPath: "/dashboard",
});
}}
>
Login
</button>
</div>
);
};
usePlatform hookThe hook that provides utility functions for Tailor Platform specific operation. It includes:
getCurrentUser: A function to retrieve the logged-in user's information using a valid session token.Here is an example of how to use these functions:
"use client";
import { usePlatform } from "@tailor-platform/oidc-client";
const Component = async () => {
const { token } = useSession();
const { getCurrentUser } = usePlatform();
const user = await getCurrentUser(token);
// utilize session and user data...
};
getServerSession hookA function to get token on server components that can be imported from @tailor-platform/oidc-client/server.
"use server";
import { getServerSession } from "@tailor-platform/oidc-client/server";
const Page = () => {
const session = getServerSession();
return <div>Token: {session.token}</div>;
};
This package provides adapters to integrate authentication with third-party packages.
@tailor-platform/oidc-client/adapters/apollo is a package with custom ApolloLink that automatically sets tokens in authorization header as a bearer token.
"use client";
import { ApolloClient, InMemoryCache } from "@apollo/client";
import { authenticatedHttpLink } from "@tailor-platform/oidc-client/adapters/apollo";
import { TailorAuthProvider } from "@tailor-platform/oidc-client";
import dynamic from "next/dynamic";
import { config } from "@/libs/authConfig";
const ApolloProvider = dynamic(
() => import("@apollo/client").then((modules) => modules.ApolloProvider),
{ ssr: false },
);
const client = new ApolloClient({
link: authenticatedHttpLink(config),
cache: new InMemoryCache(),
});
export const Providers = ({ children }: { children: ReactNode }) => {
return (
<TailorAuthProvider config={config}>
<ApolloProvider client={client}>
{children}
</ApolloProvider>
</TailorAuthProvider>
);
};
FAQs
This package provides ways to handle Tailor authentication
We found that @tailor-platform/oidc-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.