2.0.12 • Published 4 years ago

cidaas-interceptor v2.0.12

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

This project is deprecated and no longer maintained.

Please use the cidaas-interceptor-nodejs instead: https://www.npmjs.com/package/cidaas-interceptor-nodejs

Add the cidaas interceptor : node js (with express js)

npm install cidaas-interceptor --save

Usage

Cidaas Interceptor works as middleware for express nodeJS servers.

Express js

var express = require('express');
var app = express();
var bodyParser = require("body-parser");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));

// import and configure cidaas intcerceptor
var cidaasConfig = require("./Resources/configs/cidaas-service.json");
var cidaas_interceptor = require("cidaas-interceptor")(cidaasConfig);

Check Scope

app.get("/serviceurl", cidaas_interceptor({ scopes: ["cidaas:write"] }), function (req, res) {

// your code

});

Check Role

app.post("/serviceurl", cidaas_interceptor({ roles: ["Admin"] }), function (req, res) {

// your code

});

Check Role and Scope

app.get("/serviceurl", cidaas_interceptor({ scopes: ["cidaas:write"], roles: ["Admin"] }), function (req, res) {

// your code

});

DenyAll

app.get("/serviceurl", cidaas_interceptor({denyAll : true}), function (req, res) {

// your code

});

PermitAll

app.get("/serviceurl", cidaas_interceptor({permitAll : true}), function (req, res) {

// your code

});

OR just ignore the inceptor code

app.get("/serviceurl", function (req, res) {

// your code

});

Required Property file :

vim cidaas-service.json

{
"user_info_by_token" : "cidaas url",
"update_token_check_url":"update token url"
}

Load properties to cidaas interceptor

var cidaasConfig = require("./Resources/configs/cidaas-service.json");
var cidaas_interceptor = require("cidaas-interceptor")(cidaasConfig);

Property Details

FieldDefault ValueRequiredMax
user_info_by_token""Yes
update_token_check_url""Yes
tokenKey"access_token"No
updateIntervalInSec5000No10000

Note

node vs java interceptor comparison

  • Unlike the Java interceptor, you have to add cidaas middleware in all of your required route methods. If the method does not have the cidaas interceptor middleware, this is the same as java's @PermitAll

  • Java's @OAuthScopes(scopes = { "cidaas:write", ... }) == cidaas_interceptor({ scopes: ["cidaas:write", ...]})

  • Java's @RolesAllowed(value = { "role1", "role2", ... }) == cidaas_interceptor({ roles: ["role1", "role2", ...]})

  • Don't have support for JWE

2.0.12

4 years ago

2.0.11

4 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.22

6 years ago

1.3.21

6 years ago

1.3.20

6 years ago

1.3.19

6 years ago

1.3.18

6 years ago

1.3.17

6 years ago

1.3.16

7 years ago

1.3.15

7 years ago

1.3.14

7 years ago

1.3.13

7 years ago

1.3.12

7 years ago

1.3.11

7 years ago

1.3.10

7 years ago