Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@backstage/plugin-user-settings-backend

Package Overview
Dependencies
Maintainers
0
Versions
832
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage/plugin-user-settings-backend

The Backstage backend plugin to manage user settings

  • 0.2.27
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
increased by16.46%
Maintainers
0
Weekly downloads
 
Created
Source

User settings backend

This backend allows to save user specific settings. All requests need to be authorized, as the user identifier (userEntityRef) is resolved using the authorization token.

Setup backend

Install the backend plugin

# From your Backstage root directory
yarn --cwd packages/backend add @backstage/plugin-user-settings-backend @backstage/plugin-signals-backend

Add the plugin to your backend in packages/backend/src/index.ts:

backend.add(import('@backstage/plugin-user-settings-backend'));
// The signals backend is technically optional but enables real-time update of user
// settings across different sessions
backend.add(import('@backstage/plugin-signals-backend'));

Setup app

To make use of the user settings backend, replace the WebStorage with the UserSettingsStorage by using the storageApiRef.

 // packages/app/src/apis.ts
 import {
   AnyApiFactory,
   createApiFactory,
+  discoveryApiRef,
+  fetchApiRef,
   errorApiRef,
+  identityApiRef,
+  storageApiRef,
 } from '@backstage/core-plugin-api';
+import { UserSettingsStorage } from '@backstage/plugin-user-settings';
+import { signalApiRef } from '@backstage/plugin-signals-react';

 export const apis: AnyApiFactory[] = [
+  createApiFactory({
+    api: storageApiRef,
+    deps: {
+      discoveryApi: discoveryApiRef,
+      errorApi: errorApiRef,
+      fetchApi: fetchApiRef,
+      identityApi: identityApiRef,
+      signalApi: signalApiRef, // Optional
+    },
+    factory: deps => UserSettingsStorage.create(deps),
+  }),
 ];

Development

Use yarn start to start the local dev environment. To simplify the access to the API, the token will automatically be set to user:default/john_doe.

You can change the user by setting a custom Authorization header. To keep things simple, the raw Bearer value will directly be used as user.

Example:

curl --request GET 'http://localhost:7007/user-settings' --header 'Authorization: Bearer user:default/custom-user'

FAQs

Package last updated on 19 Nov 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc