🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@zekecato/gatsby-theme-auth0

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@zekecato/gatsby-theme-auth0

A Gatsby theme for Auth0

unpublished
latest
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

@zekecato/gatsby-theme-auth0 🔐

A Gatsby theme for adding Auth0 to your application.

What's in the box?

  • 💯 Easy to set up authentication.
  • 🔑 SSO.
  • 🔋 Batteries included: [AuthService] & [useAuth]
  • 🤙 [/auth/callback] page automatically set up. Configurable via callbackPath
  • 🎨 Fully customizable & extendable.

Based on https://github.com/epilande/gatsby-theme-auth0 BUT!!

  • No typescript
  • Updated Dependencies
  • Configurable Logout Redirect Path

Installation

$ npm install --save @zekecato/gatsby-theme-auth0

Usage

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: "@zekecato/gatsby-theme-auth0",
      options: {
        domain: process.env.AUTH0_DOMAIN,
        clientID: process.env.AUTH0_CLIENT_ID,
        redirectUri: process.env.AUTH0_CALLBACK_URL,
        // audience: process.env.AUTH0_AUDIENCE, // Optional
        // responseType: process.env.AUTH0_RESPONSE_TYPE, // Optional
        // scope: process.env.AUTH0_SCOPE, // Optional
        // callbackPath: "/auth/callback", // Optional
        // returnTo: "/app", // Optional
      },
    },
  ],
};

Set up your login/logout buttons and you're good to go!

import React from "react";
import { AuthService, useAuth } from "@zekecato/gatsby-theme-auth0";

export default () => {
  const { isLoggedIn, profile } = useAuth();
  return (
    <div>
      {profile && <p>Hello {profile.name}</p>}
      {isLoggedIn ? (
        <button onClick={AuthService.logout}>Logout</button>
      ) : (
        <button onClick={AuthService.login}>Login</button>
      )}
    </div>
  );
};

Theme options

KeyDefaultRequiredDescription
domaintrueConfigure Auth0 Domain
clientIDtrueConfigure Auth0 Client ID
redirectUritrueConfigure Auth0 Callback URL
audiencefalseConfigure Auth0 Audience
responseType"token id_token"falseConfigure Auth0 Response Type
scope"openid email profile"falseConfigure Auth0 Scope
callbackPath"/auth/callback"falseChange callback URL path
returnTo""falseChange logout redirect path

Shadowing

Gatsby Themes has a concept called Shadowing, which allows users to override a file in a gatsby theme. This allows the theme to be fully customizable.

To start shadowing, create a folder with the theme name gatsby-theme-auth0 in your project's src directory.

Now you're able to override any file in the theme. For example, if you want to override the callback component, create a file:

src/gatsby-theme-auth0/components/callback.js

Keywords

gatsby

FAQs

Package last updated on 19 Mar 2022

Did you know?

Socket

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.

Install

Related posts