Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
parky128 committed Jan 14, 2019
0 parents commit 671d9ac
Show file tree
Hide file tree
Showing 14 changed files with 2,321 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/*
**/vendor/*.js
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"extends": "airbnb-base"
};
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2018 ALERT LOGIC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
158 changes: 158 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
@alertlogic/aims
=========

A client for working with the AIMS Alert Logic API.

This library uses @alertlogic/client as its HTTP provider interface.

## Disclaimer

Until the release of version 1.0.0 all current minor version increments may be backwards incompatible. Please bear this in mind when developing against this library. Should you have any further questions, please do not hesitate to contact us as [[email protected]](mailto:[email protected])

## Installation

npm install @alertlogic/aims --save

## Usage

var AIMSClient = require('@alertlogic/aims')

Get Account Details

AIMSClient.getAccountDetails(accountId)
accountId: '1234'

Get Managed Accounts

AIMSClient.getManagedAccounts(accountId, queryParams)
accountId: '1234'
queryParams: {
active: true,
relationship: 'bills_to|managed|managing'
}

Enbale or disabled MFA requirement on account

AIMSClient.requireMFA(accountId, bool)
accountId: '1234',
bool: true|false

Authenticate a user

AIMSClient.authenticate(params, username, password, mfa_code);
params: {
service_name: 'aims',
path: '/authenticate'
},
username: '[email protected]',
password: 'IAmNotAValidUser!@#$',
mfa_code: '123456'

Change a users password

AIMSClient.changePassword(email, password, newPassword)
email: '[email protected]',
password: IAmNotAValidUser!@#$',
newPassword: 'ANewPasswordOfMyChoosing'

Reconstitute a logged in users identity from their AIMS Token

AIMClient.tokenInfo()

Initiate a password reset

AIMSClient.initiateReset(email, returnTo)
email: '[email protected]'',
returnTo: 'https://URLForLoginPurposes'

Complete a password reset

AIMSClient.resetWithToken(token, password)
token: 'ProvidedInEmail',
password: 'ANewPasswordOfMyChoosing'

Create a role

AIMSClient.createRole(accountId, name, permissions)
accountId: '1234',
name: 'This Is My New Role',
permissions: '{"*:own:*:*": "allowed", "aims:own:grant:*":"allowed"}'

Delete a role

AIMSClient.deleteRole(accountId, roleId)
accountId: '1234',
roleId: 'UUID-GOES-HERE'

Get Global Role

AIMSClient.getGlobalRole(roleId)
roleId: 'UUID-GOES-HERE'

Get Account Role

AIMSClient.getAccountRole(accountId, roleId)
accountId: '1234',
roleId: 'UUID-GOES-HERE'

Get all Global Roles

AIMSClient.getGlobalRoles()

Get all Account Roles

AIMSClient.getAccountRoles(accountId)
accountId: '1234'

Update a Role

AIMSClient.updateRole(accountId, name, permissions)
accountId: '1234',
name: 'The New Role Name',
permissions: '{"*:own:*:*": "allowed", "aims:own:grant:*":"allowed"}'

Update a Role Name

AIMSClient.updateRole(accountId, name)
accountId: '1234',
name: 'The New Role Name',

Update Role Permissions

AIMSClient.updateRole(accountId, permissions)
accountId: '1234',
permissions: '{"*:own:*:*": "allowed", "aims:own:grant:*":"allowed"}'

Enroll a Users MFA Device

AIMSClient.enrollMFA(uri, codes)
uri: 'otpauth://totp/Alert%20Logic:[email protected]?secret=GFZSA5CINFJSA4ZTNNZDG5BAKM2EMMZ7&issuer=Alert%20Logic&algorithm=SHA1',
codes: ["123456", "456789"]

Remove a Users MFA Device

AIMSClient.deleteMFA(email)
email: '[email protected]'

## Interactive

Loads the library into memory and stays in an interactive node shell.

npm run interactive

## Tests

npm test

## Linting

npm run lint

## Contributing

This repository follows the eslint airbnb style.

## Release History

* 0.1.0 Initial release
104 changes: 104 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Type definitions for @alertlogic/aims 0.1.0
// Project: https://github.com/alertlogic/aims-client
// Definitions by: Rob Parker <https://github.com/parky128>

import { AIMSAccount, AIMSSession, UserTimeStamp } from '@alertlogic/session';
import { ClientRequestParams } from '@alertlogic/client'

declare module '@alertlogic/aims';

interface SimpleKeyValuePair {
[key: string]: string;
}

interface AIMSRoleDetails {
id: string;
account_id: string;
permissions: SimpleKeyValuePair;
legacy_permissions: Array<any>;
version: number;
global: boolean;
created: UserTimeStamp;
modified: UserTimeStamp;
}

/**
* Get Account Details
*/
export function getAccountDetails(accountId: string): Promise<AIMSAccount>;
/**
* List managed accounts
*/
export function getManagedAccounts(accountId: string, queryParams: any): Promise<any>;
/**
* List managed account Ids
*/
export function getManagedAccountIds(accountId: string, queryParams: any): Promise<any>;
/**
* Update account details
*/
export function requireMFA(accountId: string, mfaRequired: boolean): Promise<any>;
/**
* Authenticate a user's identity
*/
export function authenticate(params: ClientRequestParams, username: string, password: string, mfa?: boolean): Promise<AIMSSession>;
/**
* Change a user's password
*/
export function changePassword(email: string, password: string, newPassword: string): Promise<any>;
/**
* Obtain Authentication Token Information (Account, User, Roles, etc.)
*/
export function tokenInfo(): Promise<string>;
/**
* Initiate the password reset process for a user
*/
export function initiateReset(email: string, returnTo: string): Promise<any>;
/**
* Reset a user's password using a token
*/
export function resetWithToken(token: string, password: string): Promise<any>;
/**
* Create a role
*/
export function createRole(accountId: string, name: string, permissions: any): Promise<any>;
/**
* Delete a role
*/
export function deleteRole(accountId: string, roleId: string): Promise<any>;
/**
* Get global role, a role that is shared among accounts.
*/
export function getGlobalRole(roleId: string): Promise<AIMSRoleDetails>;
/**
* Get role
*/
export function getAccountRole(accountId: string, roleId: string): Promise<AIMSRoleDetails>;
/**
* List global roles, roles that are shared among all accounts.
*/
export function getGlobalRoles(accountId: string, roleId: string): Promise<[AIMSRoleDetails]>;
/**
* List roles for an account. Global roles are included in the list.
*/
export function getAccountRoles(accountId: string): Promise<[AIMSRoleDetails]>;
/**
* Update Role Name and Permissions
*/
export function updateRole(accountId: string, name: string, permissions: SimpleKeyValuePair): Promise<any>;
/**
* Update Role Name
*/
export function updateRoleName(accountId: string, name: string): Promise<any>;
/**
* Update Role Permissions
*/
export function updateRolePermissions(accountId: string, permissions: SimpleKeyValuePair): Promise<any>;
/**
* Enroll an MFA device for a user
*/
export function enrollMFA(uri: string, codes: Array<string>): Promise<any>;
/**
* Remove a user's MFA device
*/
export function deleteMFA(email: string): Promise<any>;
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let AIMSClient = require('./src/index.js');

AIMSClient = new AIMSClient();

module.exports = AIMSClient;
Loading

0 comments on commit 671d9ac

Please sign in to comment.