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

@dapperduckling/keycloak-connector-group-auth-plugin

v1.1.27

Published

A plugin enabling Keycloak group permission management via Keycloak groups

Downloads

511

Readme

keycloak-connector-group-auth

Description

A custom plugin enabling permission management via Keycloak groups. Adds functionality to keycloak-connector-server.

Example Usage

/** Example usage for ARM */
/** Example usage for ARM */
router.get(
    "/members/:org_id?",
    authenticateAdmin,
    groupAuths({
        requireAdmin: true,
    }),
    async (req, res) => {
        /**
         * Require Admin logic (user must have at least one of the listed permissions)
         *  - org_id in request:
         *      - darksaber-admin
         *      - organizations/<org_id>/admin
         *  - app_id in request:
         *      - darksaber-admin
         *      - applications/<app_id>/app-admin
         *  - org_id and app_id in request:
         *      - darksaber-admin
         *      - applications/<app_id>/app-admin
         *      - applications/<app_id>/<org_id>/admin   AND organizations/<org_id>/*
         */

        /**
         * Now you have access to the following variables:
         *      body.keycloak.ga.appId    (string or null)   // The validated application id
         *      body.keycloak.ga.orgId    (string or null)   // The validated organization id
         *      body.keycloak.ga.groups   (string[] or null) // The group (or all groups) that matched this rule
         *      body.keycloak.userInfo    (object from KC) **already a part of base library
         */
    }
);


/** Example usage in a regular app */
const groupAuths = groupAuthConfig({
    app: 'fdrm',
    orgParam: 'org_id',                     // default value
    appParam: 'app_id',                     // default value
    requireAdmin: false,                    // default value
    superAdminGroup: '/darksaber-admin',    // default value
    permission: 'user',                     // default value
    listAllMatchingGroups: false,           // default value
    inheritanceTree: {
        'admin': ['supervisor'],
        'supervisor': ['user']
    },
});

router.get(
    `/:org_id/all-tools`,
    groupAuths('supervisor'),
    async (req, res) => {
        /**
         * Assuming request was '/1234-5678-90/all-tools', then...
         *
         * This route is accessible by those with any of the following groups:
         *   - `/darksaber-admin`
         *   - `/applications/fdrm/app-admin`
         *   - `/applications/fdrm/1234-5678-90/admin` AND `/organizations/1234-5678-90/*`
         *   - `/applications/fdrm/1234-5678-90/supervisor` AND `/organizations/1234-5678-90/*`
         */

    }
)

router.get(
    `/:app_id/status`,
    groupAuths('supervisor'),
    async (req, res) => {
        /**
         * Assuming request was '/ABCD-EFGH-IJ/status', then...
         *
         * This route is accessible by those with any of the following groups:
         *   - `/darksaber-admin`
         *   - `/applications/ABCD-EFGH-IJ/app-admin`
         *   - `/applications/ABCD-EFGH-IJ/<any org-id>/admin` AND `/organizations/<matching-org-id>/*`
         *   - `/applications/ABCD-EFGH-IJ/<any org-id>/supervisor` AND `/organizations/<matching-org-id>/*`
         */

    }
)

router.get(
    `/:app_id/:org_id/status`,
    groupAuths('supervisor'),
    async (req, res) => {
        /**
         * Assuming request was '/ABCD-EFGH-IJ/1234-5678-90/status', then...
         *
         * This route is accessible by those with any of the following groups:
         *   - `/darksaber-admin`
         *   - `/applications/ABCD-EFGH-IJ/app-admin`
         *   - `/applications/ABCD-EFGH-IJ/1234-5678-90/admin` AND `/organizations/1234-5678-90/*`
         *   - `/applications/ABCD-EFGH-IJ/1234-5678-90/supervisor` AND `/organizations/1234-5678-90/*`
         */

    }
)


router.get(
    `/status`,
    groupAuths('supervisor'),
    async (req, res) => {
        /**
         * Assuming request was '/status', then...
         *
         * This route is accessible by those with any of the following groups:
         *   - `/darksaber-admin`
         *   - `/applications/ABCD-EFGH-IJ/app-admin`
         *   - `/applications/ABCD-EFGH-IJ/supervisor`
         *   - `/applications/ABCD-EFGH-IJ/<any org-id>/admin` AND `/organizations/<matching-org-id>/*`
         *   - `/applications/ABCD-EFGH-IJ/<any org-id>/supervisor` AND `/organizations/<matching-org-id>/*`
         */

    }
)


router.get(
    `/status/:org_id`,
    groupAuths('supervisor', {noImplicitApp: true}),
    async (req, res) => {
        /**
         * Assuming request was '/status', then...
         *
         * This route is accessible by those with any of the following groups:
         *   - `/darksaber-admin`
         *   - `/organizations/ABCD-EFGH-IJ/app-admin`
         *   - `/organizations/ABCD-EFGH-IJ/supervisor`
         */

    }
)


/** Standalone function call */
// Use case: Endpoint exists to take N-number organization ids through a form POST, and need to confirm permissions
const hasPermission = groupAuthCheck({
    org_id: '1234-5678-90',
}, {
    requireAdmin: true,
    // ...add any other groupAuthConfig parameters
});

// Or even checking a certain privilege in each app
const hasPermission = groupAuthCheck({
    app_id: '1234-5678-90',
}, {
    permission: 'supervisor'
    // ...add any other groupAuthConfig parameters
});