New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@permify/vue-permify

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

@permify/vue-permify

Permify Vue library provides a plugin, vue-router middleware and components for controlling access checks throughout your entire Vue application with using Permify API.

unpublished
latest
Source
npmnpm
Version
2.0.2
Version published
Maintainers
1
Created
Source

@permify/vue-permify

npm Twitter Follow

Permify Vue library provides a plugin, vue-router middleware, and components for controlling access checks throughout your entire Vue application via Permify API.

Installation

Use npm to install:

npm install @permify/vue-permify

How to use

isAuthorized(policy, action)

isAuthorized is a helper function that returns a Promise which resolves with true if the user is authorized for action with the given parameters, if not it resolves with false.

You should call it inside a conditional logic structure; maybe in conditionaly rendering UI or a simple if check for fetching protected information.

Parameters

  • policyName (mandatory)
    Custom Permify Policy name.

  • Action (mandatory)
    Custom Policy Action.

  • resourceId (optional)
    Id of the Resource, mandatory if any resource used or accessed when creating Rule/Rules.

  • resourceType (optional)
    Type or name of the Resource, mandatory if any resource used or accessed when creating Rule/Rules.

Using isAuthorized function:

<template>
  <div v-if="isAuthorized">
   /*  protected component, UI Layer etc. */
  </div>
</template>

<script>
export default {
  data() {
    return {
      isAuthorized:  false,
    };
  },
  async created() {
        //post-edit passed as policyName parameter
        if (await this.$permify.isAuthorized('posts', 'edit', '91', 'post')) {
             // request protected info from server
        }
    }
};
</script>

routeGuard

routeGuard is a vue-router middleware function that you can use to control the access management of your pages.

Props

  • policyName (mandatory)
    Custom Permify Policy name.

  • action (mandatory)
    Custom Policy action.

  • resourceId (optional)
    Id of the Resource, mandatory if any resource used or accessed when creating Rule/Rules.

  • resourceType (optional)
    Type or name of the Resource, mandatory if any resource used or accessed when creating Rule/Rules.

  • redirectTo (mandatory)
    redirect url if user has not authorized to view the page (mandatory)

<template>
    /*  create contact UI */
</template>

<script>
import { routeGuard } from "@permify/vue-permify";

export default {
    beforeRouteEnter: routeGuard({
        policyName="'contacts'"
        action="'create'"
        redirectTo: "/unauthorized",
    })
}
</script>

Documentation

https://docs.permify.co/docs/intro

Contact Us

info@permify.co
hello@permify.co

License

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Keywords

vue

FAQs

Package last updated on 03 May 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