npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

strapi-googleauth-extended

v0.0.2

Published

This is the description of the plugin.

Downloads

3

Readme

Strapi plugin strapi-googleauth-extended

strapi-googleauth-extended

strapi-googleauth-extended is a Strapi plugin that simplifies Google OAuth authentication for your users. With seamless integration into Strapi's user management system, this plugin helps you manage user login and profile information efficiently. The plugin uses Google's OAuth 2.0 authorization to retrieve user details and ensures secure JWT-based authentication. It's an enhanced version of the strapi-google-auth plugin by storing the registered users in the strapi

Features

  1. Official Google API integration
  2. Strapi's default user-permission collection integration
  3. JWT authentication for secure access
  4. Automatic handling of first-time registrations
  5. User-friendly and customizable
  6. Secure and sanitized responses

FlowChart

Google-Auth-FlowChart

Installation

Install the plugin via npm or yarn:

npm install strapi-googleauth-extended

or

yarn add strapi-googleauth-extended

Activate the plugin by adding the following lines to your config/plugins.js file:

module.exports = {
  "strapi-google-auth-extended": {
    enabled: true,
  },
};

Configuration

Setting up Google OAuth

  1. Create a Google Cloud Project:

    . Go to the Google Cloud Console. . Create a new project or select an existing one.

  2. Create OAuth Consent Screen:

    . In the left navigation menu, go to APIs & Services > OAuth consent screen. . Set up your consent screen by providing the required information, such as application name, support email, and scopes.

  3. Create OAuth Client ID:

    . Navigate to Credentials. . Click Create Credentials and select OAuth Client ID. . Configure the OAuth Client by choosing "Web Application" and specifying your Authorized redirect URIs.

  4. Obtain Client ID and Client Secret:

    . After creating the OAuth client, you will receive a Client ID and Client Secret. Save these details for later use.

  5. Set Up Redirect URL and Scopes:

    . Add your redirect URL (e.g., https://yourapp.com/callback) in the OAuth Client configuration. . Define the scopes required for your application (e.g., email, profile).

Plugin Configuration in Strapi

. In the Strapi Admin panel, navigate to the plugin settings page.
. Enter your Client ID, Client Secret, Redirect URL, and the required scopes in the respective fields.
. Save your settings.

Usage

Step 1: Initialize Google Authentication

To initiate Google login, make a GET request to the following endpoint:

{
    method: 'GET',
    path: 'STRAPI_BACKEND_URL/strapi-googleauth-extended/init',
}

This will redirect your users to the Google login page. After a successful login, Google will redirect the user back to your specified redirect URL with an authorization code as a query parameter:

arduino Copy code https://REDIRECT_URL?code=AUTH_CODE

Step 2: Authenticate User

Use the received authorization code to authenticate the user by making a POST request to the following endpoint:

{
    method: 'POST',
    path: 'STRAPI_BACKEND_URL/strapi-googleauth-extended/user-profile',
    data: {
        code: AUTH_CODE
    }
}

This will generate a JWT token for the authenticated user.

Step 3: Get Authenticated User Details

To retrieve the authenticated user's details, use the JWT token obtained in the previous step:

{
    method: 'GET',
    path: 'STRAPI_BACKEND_URL/strapi-googleauth-extended/me',
    headers: {
        Authorization: 'Bearer <TOKEN>'
    }
}

Step 4: Update User Password

If you need to allow users to update their passwords, send a POST request with the JWT token and new password:

{
    method: 'POST',
    path: 'STRAPI_BACKEND_URL/strapi-googleauth-extended/update-password',
    headers: {
        Authorization: 'Bearer <TOKEN>'
    },
    data: {
        "password": "<NEW_PASSWORD>"
    }
}

Video Documentation

GoogleAuth-Frontend-Video

User Management

The plugin will automatically store new users in Strapi's Users content manager when they log in for the first time. If the user already exists, they will not be added again.

Security and Best Practices

Ensure that your Strapi installation is secure by using HTTPS. Regularly update your Google OAuth credentials and monitor your Google Cloud project for security alerts.