@bigbinary/neeto-access-control-frontend

中文文档
1.6.0发布于 2026/11/03UNLICENSEDTypeScriptESM + CJS近 30 天下载 1.2万

Neeto access control

原始使用文档
文档目录8 节
  1. Engine
  2. Installation
  3. Frontend package
  4. Installation
  5. Components
  6. Hooks
  7. Customize option labels in the host application with transl…
  8. Password authentication not working in embedded pages durin…

neeto-access-control-nano

The neeto-access-control-nano manages access control across neeto products. The nano exports the @bigbinary/neeto-access-control-frontend NPM package and neeto-access-control-engine Rails engine for development.

Contents

  1. Development with Host Application
  2. Instructions for Publishing
  3. Releasing beta versions

Development with Host Application

Engine

The engine is used to manage access control across neeto products.

Installation

  1. Add the gem in Gemfile

      source "NEETO_GEM_SERVER_URL" do
        # ..existing gems
    
        gem "neeto-access-control-engine"
      end
    
  2. Install the gem

      bundle install
    
  3. Add required migrations in the db/migrate folder. Run the following commands to copy the migrations from the engine to the host application. Ex: neetoForm

      bundle exec rails neeto_access_control_engine:install:migrations
      bundle exec rails db:migrate
    
  4. Add this line to your application's config/routes.rb file:

      mount NeetoAccessControlEngine::Engine => "/secure"
    
  5. Add has_one association to the model you want to add the access control configuration. For Example - The organization only needs single access control.

      class Organization < ApplicationRecord
        has_one :access_control_configuration, as: :owner, class_name: "NeetoAccessControlEngine::Configuration", dependent: :destroy
      end
    
  6. Your controller must include the concern and access_control_configuration method.

      class PublicController < ApplicationController
        .
        .
        include NeetoAccessControlEngine::Authenticate
        .
        private
    
          def access_control_configuration
            @_access_control_configuration ||= @organization.access_control_configuration
          end
      end
    
  7. Add overrides for the following files:

  • 7.1. google_controller_override.rb

      NeetoAccessControlEngine::GoogleController.class_eval do
        private
    
          def access_control_configuration
            @_access_control_configuration ||= @organization.access_control_configuration
          end
      end
    
  • 7.2. invitations_controller_override.rb (Optional)

    • Methods
      • access_control_configuration
      • after_invitations_created

        If host app doesn't have an override method for the controller, then neeto_access_control_configuration_id parameter must be included in the request params.

      NeetoAccessControlEngine::Api::V1::Configurations::InvitationsController.class_eval do
        private
    
          def access_control_configuration
            @_access_control_configuration ||= @organization.access_control_configuration
          end
    
          # after_action callback, called after invitations are created.
          # Use to send invitation emails or perform any post-invitation tasks.
          def after_invitations_created
            # @invited_emails is loaded in engine
            return if @invited_emails.blank?
    
            EmailInvitationsJob.perform_async(@invited_emails, current_user.id)
          end
      end
    
  • 7.3. guest_sessions_controller_override.rb

      NeetoAccessControlEngine::GuestSessionsController.class_eval do
        private
    
          def access_control_configuration
            @_access_control_configuration ||= @organization.access_control_configuration
          end
      end
    
  • 7.4. configurations_controller_override.rb

      NeetoAccessControlEngine::Api::V1::ConfigurationsController.class_eval do
    
        private
    
          def owner
            @organization
          end
    
          def update_owner!
            # Optional override to update the owner if required when configuration is updated
          end
      end
    
  1. Add Google OAuth support
  • 8.1. Create Google OAuth account Watch the demo video for step-by-step instructions on creating a Google OAuth account. Add the authorised redirect URI: https://connect.neetokb.net/secure/google_oauth2/callback

  • 8.2. Set the env variables Add the following secret values to config/secrets.yml.

    google:
      client_id: <%= ENV['GOOGLE_OAUTH_CLIENT_ID'] %>
      client_secret: <%= ENV['GOOGLE_OAUTH_CLIENT_SECRET'] %>
    

Frontend package

Installation

  1. Install the latest neeto-access-control-frontend package using the below command:
      yarn add @bigbinary/neeto-access-control-frontend
    

Components

1. Configuration (source code)

Props

  • ownerId: To specify the ID of the instance of the model. The ID is used to fetch and update access control configuration.
  • ownerType: Type of the model.
  • onReset: Callback function that is triggered when the reset button is clicked.
  • onSuccess: Callback function that is triggered when the configuration is successfully updated.
  • handleCancel: Callback function that is triggered when the cancel button is clicked.
  • invitationsTableExtraColumnsData: Prop to add column data for invitations table. This will override the existing column if the key is already present. Refer Column data
  • onConfigurationChangedToInviteOnly: Callback function that is triggered when configuration is changed to invited. Default: noop.
  • headerProps: Props passed to the Header component from neetoMolecules.
  • hideAddEmailsFromInvitationPane: Prop to hide the add emails form from invitation pane. Default: false.
  • className: Additional classes to be added to the form.
  • onDestroyInvitationsSuccess: Callback function that is triggered when the invitations are successfully destroyed.
  • inviteButtonProps: If specified, this will show a button on the top of the Pane. It can be used to take the users to invitation forms outside the InvitationsPane.
  • additionalFieldsInitialValues: Prop to add additional custom fields to the form.
  • fieldsWrapper: A component that wraps the fields in the form. Useful for adding custom fields to the form.
  • translationContext: Context for translations, it can be used to override the translations of the field labels. Ref: https://www.i18next.com/translation-function/context
  • transProps: Props for the Trans component used in the form field labels. Each field label can be customized by passing the props in the transProps object mapped to the auth type: no, basic, email, session, invited.
  • enableNavigationBlocking: If true, renders the BlockNavigation component from neetoUI to show alert when having unsaved changes in the form.

2. Invitations Object

The Invitations object provides access to invitation-related components, hooks, and constants.

Components

InvitationsPane (source code)

Props

Check source code for default values

  • onClose: Callback function that is triggered when the close button is clicked.
  • isOpen: Prop for pane, will reflect state of the pane.
  • extraColumnsData: Prop to add column data for invitations table. This will override the existing column if the key is already present. Refer Column data
  • ownerId: To specify the ID of the instance of the model. The ID is used to fetch and update access control configuration.
  • ownerType: Type of the model.
  • hideAddEmailsForm: Prop to hide the add emails form from invitation pane.
  • configurationId: Prop to specify the ID of the instance of the model. The ID is used to load access control configuration. NOTE: If this prop is not passed, make sure invitations_controller_override.rb is added with access_control_configuration method as mentioned above in adding overrides section.
  • onDestroyInvitationsSuccess: Callback function that is triggered when the invitations are successfully destroyed.
  • inviteButtonProps: If specified, this will show a button on the top of the Pane. It can be used to take the users to invitation forms outside the InvitationsPane.

Hooks

Constants

  • INVITATIONS_QUERY_KEY: For react query cache of invitations

Invitations object usage

/* Required imports */
import { Invitations } from "@bigbinary/neeto-access-control-frontend";

const { InvitationsPane, useBulkCreateInvitations, INVITATIONS_QUERY_KEY } =
  Invitations;

const MyComponent = () => {
  const [showInviationsPane, setShowInviationsPane] = useState(false);
  const [emails, setEmails] = useState("");

  const { mutateAsync: addEmails } = useBulkCreateInvitations({
    configurationId: null,
  });

  const queryClient = useQueryClient();

  const addTestEmails = async () => {
    const payload = { emails: emails.split(",") };
    await addEmails(payload);
    setEmails("");
    queryClient.invalidateQueries({
      queryKey: [INVITATIONS_QUERY_KEY],
    });
  };

  return (
    <div className="space-4 p-5">
      <Input
        label="Email"
        value={emails}
        onChange={e => setEmails(e.target.value)}
      />
      <Button label="Add test email " onClick={addTestEmails} />
      <Button
        label="Open Invitation pane"
        onClick={() => setShowInviationsPane(true)}
      />
      <InvitationsPane
        hideAddEmailsForm
        isOpen={showInviationsPane}
        onClose={() => setShowInviationsPane(false)}
      />
    </div>
  );
};

Usage

This is an example usage in neetoKB

import React from "react";

import { Configuration } from "@bigbinary/neeto-access-control-frontend";

import { HELP_SECURITY_DOC_URL } from "src/constants/urls";

import { buildDefaultBreadcrumbs } from "./utils";

const AccessControl = () => {
  return (
    <Configuration
      className="mx-auto max-w-3xl md:px-0 lg:px-6"
      handleCancel={() => {}}
      headerProps={{
        title: "Access control",
        description: "Access control description",
        helpLink: HELP_SECURITY_DOC_URL,
        breadcrumbs: buildDefaultBreadcrumbs({
          title: "Access control",
        }),
      }}
    />
  );
};

export default AccessControl;

Hooks

1. useShowConfiguration

This is a React Query hook for fetching access control configuration of specified owner.

Arguments

  • ownerId: To specify the ID of the model instance. This ID will be used to fetch access control configuration.
  • ownerType: Type of the model.

Usage

const {
  data: { configuration },
} = useShowConfiguration({ ownerId, ownerType });

Customize option labels in the host application with translations

To customize option labels for authentication, you can set the translations from the host application. To set the translations from the host application:

  • Open the en.json file.
  • Add translations for the auth option labels under the neetoAccessControl.auth namespace. For Example:
    {
      "neetoAccessControl": {
        "auth": {
          "no": "No auth label",
          "basic": "Basic auth label",
          "email": "Email auth label"
          "session": "Session auth label"
        }
      }
    }
    

Troubleshooting

Password authentication not working in embedded pages during development

When a password-protected page is embedded in an iframe, the authentication may fail in development — the password page keeps showing even after entering the correct password. This happens because the iframe's session cookie is treated as a third-party cookie, and browsers block third-party cookies over HTTP.

Fix: Place the test HTML file in the host application's public/ directory and access it at the same origin as the dev server (e.g., http://spinkart.lvh.me:9026/test-embed.html). This makes the iframe's session cookie first-party, avoiding the third-party cookie restriction.

This is not an issue in production since HTTPS allows SameSite=None; Secure cookies to work in iframes.

Instructions for Publishing

Consult the building and releasing packages guide for details on how to publish.

Releasing beta versions

  • Push the changes to a target branch for releasing the beta version.
  • Update the package version to {latest-version}-beta (if 1.2.34 is the current latest version, it will be 1.2.34-beta) in the target branch for beta release.
  • Draft a new release from the repo with the target branch.
  • Add a new tag and title in the format: version prefixed with v, eg: v1.2.34-beta.
  • Generate release notes.
  • Set the release as a pre-release and publish the release.

If we are releasing a beta version of a product, we have to inform the compliance team as well to avoid overwriting the version with the latest version on the next compliance release.

版本与发布记录

@bigbinary/neeto-access-control-frontend 共发布 71 个版本,首次发布于 2024/03/21;过去 12 个月发布了 35 个版本。

版本发布日期距今
1.6.0latest2026/11/035 天前
1.6.0-beta1beta2026/11/035 天前
1.5.22026/11/017 天前
1.5.2-beta22026/11/017 天前
1.5.2-beta12026/10/309 天前
1.5.12026/10/309 天前

关于 @bigbinary/neeto-access-control-frontend 的常见问题

@bigbinary/neeto-access-control-frontend 是什么?

Neeto access control

如何安装 @bigbinary/neeto-access-control-frontend?

在项目目录运行 npm install @bigbinary/neeto-access-control-frontend,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:qs(6.16.2)、url(0.11.4)、yup(0.32.11)、antd(5.22.1)、util(^0.12.5)、axios(1.20.0)、ramda(0.29.0)、react(18.3.1)、buffer(^6.0.3)、formik(2.4.6)、i18next(22.5.1)、zustand(4.4.2)、dompurify(3.4.17)、js-logger(1.6.1)、react-dom(18.3.1)、classnames(2.5.1)、stream-http(3.2.0)、tailwindcss(^4.1.17)、lucide-react(^1.7.0)、react-helmet(^6.1.0)、os-browserify(0.3.0)、react-i18next(12.3.1)、vm-browserify(1.1.2)、@babel/runtime(7.29.7)、react-toastify(8.0.2)、tty-browserify(0.0.1)、path-browserify(^1.0.1)、https-browserify(1.0.0)、mixpanel-browser(^2.45.0)、react-router-dom(5.3.3)、crypto-browserify(3.12.1)、source-map-loader(4.0.1)、stream-browserify(^3.0.0)、@bigbinary/neetoui(8.8.3)、@honeybadger-io/js(6.10.1)、@bigbinary/neeto-cist(1.0.17)、@honeybadger-io/react(6.1.25)、@tanstack/react-query(5.59.20)、@bigbinary/neeto-atoms(1.1.2)、@bigbinary/neeto-icons(1.20.89)、@bigbinary/neeto-molecules(5.9.15)、@tailwindcss/container-queries(^0.1.1)、@tanstack/react-query-devtools(5.59.20)、@bigbinary/neeto-commons-frontend(4.14.8)、@bigbinary/neeto-filters-frontend(4.7.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bigbinary/neeto-access-control-frontend 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bigbinary/neeto-access-control-frontend 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bigbinary/neeto-access-control-frontend 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bigbinary/neeto-access-control-frontend 可以商用吗?

@bigbinary/neeto-access-control-frontend 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@bigbinary/neeto-access-control-frontend 的下载量有多少?

根据 npm 官方下载统计,@bigbinary/neeto-access-control-frontend 在 2026/10/08 – 2026/11/06 这 30 天内被下载 11,522 次,日均约 384 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bigbinary/neeto-access-control-frontend 还在维护吗?

最新版本 1.6.0 发布于 2026/11/03(5 天前);至今共发布 71 个版本,其中过去 12 个月发布了 35 个;首次发布于 2024/03/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。