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

loopback-component-cas

v0.5.21

Published

Loopback CAS Authentification

Downloads

36

Readme

loopback-component-cas

This component provides a loopback native implementation of a CAS Protocol Specification.

Use it with loopback

DONE : CASv1, CASv2, CASv3, SAMLv1.1

TODO : SLO logout, SAMLv2, Regression Test

Installation

  • npm i loopback-component-cas
  • Don't forget to add express-xml-bodyparser to your project

Configuration

Application Model

You MUST use application model to store RegExp url field.

User Model

User model MUST have a profile entry with user JSON profile AND uuid for each user.

Example in common/models/account.json:

{
  "name": "Account",
  "base": "User",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "uuid": {
      "type": "string",
      "required": true
    },
    "profile": {
      "type": "string"
    }
  },
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": {}
}

AccessToken model

In model-config.json, add appId field and modify belongsTo relation to use Account.

"AccessToken": {
  ...
  "relations": {
    "application": {
      "type": "belongsTo",
      "model": "Application",
      "foreignKey": "appId"
    },
    "user": {
      "type": "belongsTo",
      "model": "Account",
      "foreignKey": "userId"
    }
  }
}

login and logout WEB Pages

CAS redirect on theses pages if necessary.

login Page parameter

  • redirect [OPTIONAL] - the full URL-encoded cas login service as described in section 2.2 of RFC 3986 (ex. ${accessUrl}/cas/login?service=serviceUrl)

logout Page parameter

  • redirect [OPTIONAL] - the full URL-encoded service URL as described in section 2.2 of RFC 3986

token, cookie-parser and express-xml-bodyparser

In server/middleware.json, add in request cookie-parser, token and express-xml-bodyparser

"session:before": {
   "cookie-parser": {
     "params": "${cookieSecret}"
   }
},
"auth": {
  "loopback#token": {
    "params": {
      "model": "AccessToken"
   }
  }
},
"parse": {
  "express-xml-bodyparser": {
    "params": {
     "normalize": true,
     "normalizeTags": false,
     "explicitArray": false
    }
  }
}

Don't forget to add config.json#cookieSecret.

Component configuration

In server/component-config.json

"./components/loopback-component-cas": {
  "accessUrl": "https://my.access.Url"
  "serviceTicketTTL": 60000,
  "loginPage": "/account/signin",
  "logoutPage": "/account/signout",
  "userModel": "User",
  "attributes": [
    "authenticationDate",
    "longTermAuthenticationRequestTokenUsed",
    "isFromNewLogin",
    "memberOf",
    "email",
    "displayName",
    "firstname",
    "lastname",
    "languages",
    "userId",
    "uuid"
  ],
  "loginCallback": "loginCallback"
}

${userModel}.uuid is always injected

Attributes may comply with contact schema established by [Joseph Smarr][schema-author].

Attributes can be any key from ${userModel}.profile.

If optional loginCallback(req, service, user) exist, loopback-component-cas call it when login occure.

Specific case

  • email come from model ${userModel}.email
  • firstname come from ${userModel}.profile.name.givenName
  • lastname come from ${userModel}.profile.name.familyName