@asymmetrik/crowd-authenticator

0.2.0 • Public • Published

@asymmetrik/crowd-authenticator

Build Status Code Climate Test Coverage standard-readme compliant

Authenticator for creating sessions with Atlassian Crowd. The authenticator wraps the logic necessary to sync Crowd with an external authentication system.

Table of Contents

Install

Include this module as a dependency of your application in the package.json file. For example:

{
  ...
  dependencies: {
    "@asymmetrik/crowd-authenticator": "latest"
  }
  ...
}

Usage

Include the module via require wherever applicable:

let CrowdAuthenticator = require('@asymmetrik/crowd-authenticator');
let CrowdClient = require('atlassian-crowd-client');

// Create the crowd client
let crowdClient = new CrowdClient({
	baseUrl: 'http://localhost:8095/crowd/',
	application: {
		name: 'crowd-authenticator',
		password: 'password'
	}
});

// Create a custom config
let config = {
	passwordStrategy: () => { return Promise.resolve('password'); },
	groupPrefix: 'prefix:',
	defaultGroups: [ 'jira-user', 'confluence-user' ]
};

// Create the authenticator instance
let crowdAuthenticator = CrowdAuthenticator(crowdClient, config);

let userInfo = {
	firstname: 'Test',
	lastname: 'User',
	displayname: 'Test User',
	email: 'test@email.com',
	username: authId,
	groups: [ 'one', 'two' ]
};

// Authenticate
crowdAuthenticator.authenticate(userInfo)
	.then((session) => {
		// session contains token and expiration information
		// at this point, crowd will contain the defaultGroups plus all groups on the userInfo
	);

API

See above Usage example.

Contribute

PRs accepted.

License

See LICENSE for details

Readme

Keywords

none

Package Sidebar

Install

npm i @asymmetrik/crowd-authenticator

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • rblace