Code Monkey home page Code Monkey logo

aio-cli-plugin-ims's Introduction

aio-cli-plugin-ims

DEPRECATED IN FAVOR OF THE AUTH PLUGIN

The IMS plugin to aio supports managing tokens for IMS such as login, logout, and retrieving and using tokens.

oclif Version Downloads/week Build Status License Codecov Coverage

Motivation

IMS integration for authentication and subsequent use of the CLI for service access is critical to the success of the CLI. To that avail, this functionality needs to be as complete as to support anything the browser UI supports as well. In the end, this means support for logging in not only with JWT tokens for technical accounts but also leveraging the SUSI flow for three-legged user based authentication and even, at least for Adobe internal teams, with service tokens.

The current JWT Auth Plugin for the Adobe I/O CLI does a decent job supporting JWT based flows with some limitations, though:

  • Only a single configuration is supported, thus not allowing to switch for different configurations and thus different setups depending on the actual CLI task at hand. Even with the new local configuration support we are still limited to one configuration per local environment.
  • The configuration contains a lot of boiler plate data, which is the same for many configurations. This also makes the configuration hard to manage.
  • Only JWT tokens are supported. So we are missing real user tokens created using the SUSI UI based flow as well as service tokens, which are sometimes used by Adobe internal teams.
  • The actual JWT signing and token exchange are not easily re-usable outside of the CLI plugin.

Goals

So the goal of this project along with the companion repositories is to provide more complete support:

  • Have a separate module implementing a JavaScript interface to the IMS API, so that this IMS API can be leveraged from multiple places, inside of the Adobe I/O CLI IMS Plugins or outside.
  • Store as little information in the configuration data as possible. This boils down to the absolutely needed fields, such as client_id, client_secret, private_key etc. The boilerplate, such as the bulk of the JWT token should be provided dynamically.
  • The plugins should support all three of the login mechanism: SUSI/UI based for user token, JWT based (technical/utility) user tokens, as well as Adobe-internal service tokens.

The JavaScript Packages

Without much further ado, here is the collection of IMS supporting plugins:

  • The Adobe I/O Lib Core IMS Support Library is the reusable base library providing JavaScript level API to the IMS APIs as well as getting access to tokens. All the functionality of this library is available by simply requiring this library.
  • This Adobe I/O CLI IMS Plugin is the main CLI plugin to the Adobe IO CLI. See #plugin for more details below.
  • Three extension to the Adobe IO IMS Support Library supporting creation of IMS tokens for different use cases. They all come as node packages. They are used by the Adobe IO IMS Support Library to implement the access token creation. The plugins are:

How it works

This Adobe IO CLI IMS Plugin offers four commands:

  • login to create and return IMS access tokens. Since tokens are cached in the Adobe IO CLI configuration, an actual token is only created if the currently cached token has already expired (or is about to expire within 10 minutes).
  • logout invalidate cached tokens and remove them from the cache. Besides the access token, this can also be used to invalidate any refresh token that may be cached.
  • ctx to manage configuration contexts.
  • plugins to manage configuration contexts.
  • profile, organizations, and session to retrieve respective IMS information
  • Low level get and post to directly call IMS API using raw HTTP GET and POST requests.

PS

Oh, and yes, docs and tests are a bit lacking this time ... I want to just get this out ASAP for anyone to have a look.

Usage

$ aio plugins:install -g @adobe/aio-cli-plugin-ims
$ # OR
$ aio discover -i
$ aio ims --help

Commands

aio ims

IMS commands to login and logout.

USAGE
  $ aio ims

DESCRIPTION
  The main commands are ims:login to get or create an access token and
  ims:logout to invalidate an access token and thus log out from IMS.

  Logging in and out is based on configuration of which there may be
  multiple. Each set of configuration properties, called an IMS context,
  can be individually addressed by a label.

  Configuration for the IMS commands is stored in the "ims"
  configuration property. The special property "ims.config.current" contains the
  label of the current configuration which can be set using the
  "aio ims ctx -s <label>" command.

  Each set of properties in labeled IMS context configurations has
  configuration properties depending on the kind of access that is
  supported. The below example shows the configuration for OAuth2
  based (graphical SUSI) login.

  The "env" property is mandatory and designates the IMS environment
  used for authentication. Possible values are "stage" and "prod".
  If the property is missing or any other value, it defaults to "stage".

  All commands allow their normal output to be formatted in either
  HJSON (default), JSON, or YAML.

EXAMPLE
  {
      ims: {
        contexts: {
          postman: {
            env: "stage",
            callback_url: "https://callback.example.com",
            client_id: "example.com-client-id",
            client_secret: "XXXXXXXX",
            scope: "openid AdobeID additional_info.projectedProductContext read_organizations",
            state: ""
          }
        },
        config: {
          current: "postman"
        }
      }
    }

See code: src/commands/ims/index.js

aio ims:ctx

Manage IMS contexts.

USAGE
  $ aio ims:ctx

OPTIONS
  -c, --ctx=ctx  Name of the IMS context to use. Default is the current IMS context
  -g, --global   global config
  -l, --local    local config
  -s, --set=set  Sets the name of the current IMS context
  -v, --verbose  Verbose output
  --debug=debug  Debug level output
  --list         Names of the IMS contexts as an array
  --value        Prints named or current IMS context data

DESCRIPTION
  The following options exist for this command:

  * List the names of the configured IMS contexts
  * Print the name of the current IMS context
  * Set the name of the current IMS context
  * Print the configuration of the current or a named IMS context

  Currently it is not possible to update the IMS context configuration
  using this command. Use the "aio config" commands for this.

  Please note, that the following IMS context label names is reserved: `cli`
  and should not be used as an IMS context name.

  Also note that the current context can only be set locally.

See code: src/commands/ims/ctx.js

aio ims:get API

Call an IMS API using a GET request

USAGE
  $ aio ims:get API

ARGUMENTS
  API  The IMS API to call, for example: /ims/profile/v1

OPTIONS
  -c, --ctx=ctx    Name of the IMS context to use. Default is the current IMS context
  -d, --data=data  Request parameter in the form of name=value. Repeat for multiple parameters
  -g, --global     global config
  -l, --local      local config
  -v, --verbose    Verbose output
  --debug=debug    Debug level output

DESCRIPTION
  This is a raw and low level IMS API call command taking the IMS API
  path as the first argument and any additional request parameters
  as optional additional arguments.

  The API result is printed as an object if successful. If the call
  fails, the error message is returned as an error.

See code: src/commands/ims/get.js

aio ims:login

Log in with a certain IMS context and returns the access token.

USAGE
  $ aio ims:login

OPTIONS
  -c, --ctx=ctx  Name of the IMS context to use. Default is the current IMS context
  -d, --decode   Decode and display access token data

  -f, --force    Force logging in. This causes a forced logout on the context first and makes sure to not use any cached
                 data when calling the plugin.

  -g, --global   global config

  -l, --local    local config

  -v, --verbose  Verbose output

  --debug=debug  Debug level output

DESCRIPTION
  If the IMS context already has a valid access token set (valid meaning
  at least 10 minutes before expiry), that token is returned.

  Otherwise, if the IMS context has a valid refresh token set (valid
  meaning at least 10 minutes before expiry) that refresh token is
  exchanged for an access token before returning the access token.

  Lastly, if the IMS context properties are supported by one of the
  IMS login plugins, that login plugin is called to guide through
  the IMS login process.

  The currently supported IMS login plugins are:

  * aio-lib-ims-jwt for JWT token based login supporting
    Adobe I/O Console service integrations.
  * aio-lib-ims-oauth for browser based OAuth2 login. This
    plugin will launch a Chromium browser to guide through the
    login process. The plugin itself will *never* see the user's
    password but only receive the authorization token after the
    user authenticated with IMS.

See code: src/commands/ims/login.js

aio ims:logout

Log out the current or a named IMS context.

USAGE
  $ aio ims:logout

OPTIONS
  -c, --ctx=ctx  Name of the IMS context to use. Default is the current IMS context

  -f, --force    Invalidate the refresh token as well as all access tokens.
                 Otherwise only the access token is invalidated. For IMS
                 contexts not supporting refresh tokens, this flag has no
                 effect.

  -g, --global   global config

  -l, --local    local config

  -v, --verbose  Verbose output

  --debug=debug  Debug level output

DESCRIPTION
  This command can be called multiple times on the same IMS context with
  out causing any errors. The assumption is that after calling this command
  without an error, the IMS context's access and refresh tokens have been
  invalidated and removed from persistence storage. Repeatedly calling this
  command will just do nothing.

See code: src/commands/ims/logout.js

aio ims:organizations

Retrieve the organizations to which the user is associated

USAGE
  $ aio ims:organizations

OPTIONS
  -c, --ctx=ctx    Name of the IMS context to use. Default is the current IMS context
  -d, --data=data  Request parameter in the form of name=value. Repeat for multiple parameters
  -g, --global     global config
  -l, --local      local config
  -v, --verbose    Verbose output
  --debug=debug    Debug level output

DESCRIPTION
  This is a raw and low level IMS API call command taking the IMS API
  path as the first argument and any additional request parameters
  as optional additional arguments.

  The API result is printed as an object if successful. If the call
  fails, the error message is returned as an error.

See code: src/commands/ims/organizations.js

aio ims:post API

Call an IMS API using a POST request

USAGE
  $ aio ims:post API

ARGUMENTS
  API  The IMS API to call, for example: /ims/profile/v1

OPTIONS
  -c, --ctx=ctx    Name of the IMS context to use. Default is the current IMS context
  -d, --data=data  Request parameter in the form of name=value. Repeat for multiple parameters
  -g, --global     global config
  -l, --local      local config
  -v, --verbose    Verbose output
  --debug=debug    Debug level output

DESCRIPTION
  This is a raw and low level IMS API call command taking the IMS API
  path as the first argument and any additional request parameters
  as optional additional arguments.

  The API result is printed as an object if successful. If the call
  fails, the error message is returned as an error.

See code: src/commands/ims/post.js

aio ims:profile

Retrieve the IMS Profile (for a user token)

USAGE
  $ aio ims:profile

OPTIONS
  -c, --ctx=ctx    Name of the IMS context to use. Default is the current IMS context
  -d, --data=data  Request parameter in the form of name=value. Repeat for multiple parameters
  -g, --global     global config
  -l, --local      local config
  -v, --verbose    Verbose output
  --debug=debug    Debug level output

DESCRIPTION
  This is a raw and low level IMS API call command taking the IMS API
  path as the first argument and any additional request parameters
  as optional additional arguments.

  The API result is printed as an object if successful. If the call
  fails, the error message is returned as an error.

See code: src/commands/ims/profile.js

aio ims:session

Retrieve the IMS Profile (for a user token)

USAGE
  $ aio ims:session

OPTIONS
  -c, --ctx=ctx    Name of the IMS context to use. Default is the current IMS context
  -d, --data=data  Request parameter in the form of name=value. Repeat for multiple parameters
  -g, --global     global config
  -l, --local      local config
  -v, --verbose    Verbose output
  --debug=debug    Debug level output

DESCRIPTION
  This is a raw and low level IMS API call command taking the IMS API
  path as the first argument and any additional request parameters
  as optional additional arguments.

  The API result is printed as an object if successful. If the call
  fails, the error message is returned as an error.

See code: src/commands/ims/session.js

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

aio-cli-plugin-ims's People

Contributors

amulyakashyap09 avatar arjuncooliitr avatar dependabot[bot] avatar fmeschbe avatar greenkeeper[bot] avatar himavanth avatar meryllblanchet avatar moritzraho avatar sandeep-paliwal avatar shazron avatar yu1986 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aio-cli-plugin-ims's Issues

An in-range update of @adobe/eslint-config-aio-lib-config is breaking the build 🚨

The devDependency @adobe/eslint-config-aio-lib-config was updated from 1.0.2 to 1.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@adobe/eslint-config-aio-lib-config is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for Add jsdoc plugin, tests and travis
  • fix: add test, .travis.yml file (closes #2, closes #3) 76753d0

1.0.2...1.1.0

Commits

The new version differs by 2 commits.

  • ff9a9f1 1.1.0
  • 76753d0 fix: add test, .travis.yml file (closes #2, closes #3)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

@adobe/aio-lib-ims will require node-12 or greater starting July 14th, 2021

Your module is dependent on @adobe/aio-lib-ims.

Adobe IMS is retiring TLS 1.0 and TLS 1.1 support on July 14th, 2021.
TLSv1.2 is the default for node-12 or higher: https://nodejs.org/api/cli.html#cli_tls_min_v1_2

Therefore any calls to Adobe IMS using @adobe/aio-lib-ims using node-10 will fail after the retirement date above.

This module should impose a minimum requirement of node-12 going forward.

Add this to your package.json:

{
   "engineStrict": true, 
   "engines" : { 
         "node" : ">=12" 
    }
}

use new ims config, formerly $ims

README.md:113:  Configuration for the IMS commands is stored in the "$ims"
README.md:132:       $ims: {
src/commands/ims/index.js:32:Configuration for the IMS commands is stored in the "$ims"
src/commands/ims/index.js:52:    $ims: {
test/commands/ims/ctx.test.js:43:    $ims: {
test/commands/ims/ctx.test.js:52:  const IMS = '$ims.'
test/commands/ims/ctx.test.js:55:      return store.$ims[key.substring(IMS.length)]
test/commands/ims/ctx.test.js:62:      store.$ims[key.substring(IMS.length)] = value
test/commands/ims/ctx.test.js:72:  await expect(spy).toHaveBeenCalledWith(store.$ims.$current)
test/commands/ims/ctx.test.js:78:    data: store.$ims[myContext],
test/commands/ims/plugins.test.js:20:  $ims: {
test/commands/ims/plugins.test.js:25:const IMS = '$ims.'
test/commands/ims/plugins.test.js:28:    return store.$ims[key.substring(IMS.length)]
test/commands/ims/plugins.test.js:35:    store.$ims[key.substring(IMS.length)] = value

See adobe/aio-cli-plugin-auth#43 for new format

Depends on adobe/aio-lib-ims#46

An in-range update of @adobe/eslint-config-aio-lib-config is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye πŸ‘‹ and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency @adobe/eslint-config-aio-lib-config was updated from 1.1.0 to 1.2.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@adobe/eslint-config-aio-lib-config is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for add plugin:node/recommended to check for extraneous/missing requires
  • feat: add plugin:node/recommended to check for extraneous/missing requires (#7) 15102de
  • chore(package): update eslint-plugin-jsdoc to version 23.0.0 (#6) 849c15b
  • chore(package): update eslint-plugin-jsdoc to version 22.0.0 (#5) a3788dd
  • Update README.md 7c2e18e
  • Update dependencies to enable Greenkeeper 🌴 (#4) 3a9468d

1.1.0...1.2.0

Commits

The new version differs by 6 commits.

  • f6a0062 1.2.0
  • 15102de feat: add plugin:node/recommended to check for extraneous/missing requires (#7)
  • 849c15b chore(package): update eslint-plugin-jsdoc to version 23.0.0 (#6)
  • a3788dd chore(package): update eslint-plugin-jsdoc to version 22.0.0 (#5)
  • 7c2e18e Update README.md
  • 3a9468d Update dependencies to enable Greenkeeper 🌴 (#4)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.