Git Product home page Git Product logo

stormpath-export's Introduction

Stormpath is Joining Okta

We are incredibly excited to announce that Stormpath is joining forces with Okta. Please visit the Migration FAQs for a detailed look at what this means for Stormpath users.

We're available to answer all questions at [email protected].

stormpath-export

Easily export your Stormpath user data.

stormpath-export Release stormpath-export Downloads stormpath-export Code Quality stormpath-export Build

Box Sketch

Stormpath is Joining Okta

We are incredibly excited to announce that Stormpath is joining forces with Okta. Please visit the Migration FAQs for a detailed look at what this means for Stormpath users.

We're available to answer all questions at [email protected].

Purpose

Stormpath is one of my favorite API services. They provide a scalable, simple, and secure user management API which makes building scalable systems simple.

Whenever I talk to people about using Stormpath, the same question invariably comes up: "Is it easy to export my user data out of Stormpath? Or am I locked in?"

Up until now, the answer has been "Yes! But only if you contact them about it."

With stormpath-export, however, you can easily back up all your Stormpath user data instantly!

stormpath-export will:

  • Grab all Stormpath data you've stored, and dump it to JSON files locally.
  • Dump data into a local directory structure which makes intuitive sense (groups are located in the groups directory, etc.).
  • Each object gets it's own JSON file generated. This makes it easy to look at the file system and extract the information you need.

stormpath-export makes it easy to:

  • Download a copy of all your user data.
  • Back up your user data (Stormpath has their own backups of course, but you can never be too safe).
  • Migrate user data out of Stormpath.

Installation

Installing stormpath-export is simple -- just use pip!

Once you have pip installed on your computer, you can run the following to install the latest release of stormpath-export:

$ pip install -U stormpath-export

That's it :)

Usage

Before you can export all your Stormpath data, you'll need to configure stormpath-export and give it your Stormpath API credentials. To do this, simply run:

$ stormpath-export configure

This will prompt you for some basic information, then store your credentials in the local file ~/.stormy.

NOTE: If you are using Stormpath Enterprise, please enter https://enterprise.stormpath.io/v1 when prompted for the Base URL. This instructs the export tool to talk to the Stormpath Enterprise environment.

Next, to initiate a backup job, you can run:

$ stormpath-export

This will export all your Stormpath data, and dump it into a new directory named stormpath-exports. If you'd like to specify your own backup location, you can do so by adding a path -- for instance:

$ stormpath-export ~/Desktop/stormpath-exports

When exporting your data, you should see output similar to the following:

=== Exporting all application data...
- Exporting application: Stormpath
=== Done!

=== Exporting all directory data...
- Exporting directory: Stormpath Administrators
- Exporting directory: testdirectory
=== Done!

=== Exporting all group data...
- Exporting group: Administrators
=== Done!

=== Exporting all account data...
- Exporting account: [email protected]
=== Done!

Note

Depending on how many applications, groups, directories, organizations, and accounts you have, this process may take a while.

Once the process is finished, you can navigate the JSON files in the export directory, which will contain all your Stormpath data.

For full usage information, run stormpath-export -h:

$ stormpath-export -h
stormpath-export
----------------

Easily export your Stormpath (https://stormpath.com/) user data.

Usage:
  stormpath-export configure
  stormpath-export [(<location> | -l <location> | --location <location>)]
  stormpath-export (-h | --help)
  stormpath-export --version

Options:
  -h --help  Show this screen.
  --version  Show version.

Written by Randall Degges <http://www.rdegges.com/>.

Help

Need help? Can't figure something out? If you think you've found a bug, please open an issue on the Github issue tracker.

Otherwise, shoot us an email.

Changelog

0.1.2: 12-27-2016

  • Importing missing dependency.

0.1.1: 10-17-2016

  • Supporting --base-url argument.
  • Making the tool Python 3 compatible.

0.1.0: 03-16-2016

  • Supporting API key exports.
  • Supporting Organization exports.
  • Fixing documentation.
  • Updating Stormpath dependency.

0.0.9: 06-19-2015

  • Fixing version information.

0.0.8: 06-19-2015

  • Supporting private deployments.

0.0.7: 06-18-2015

  • Supporting Account API key backups.

0.0.6: 06-18-2015

  • Completely re-doing export structures -- much more sane now.
  • Adding IDs, hrefs, and all fields to all backups.
  • Still needs to support Social / ID site / Verification templates.

0.0.5: 05-28-2015

  • Making the application export back up directory mappings.

0.0.4: 05-27-2015

  • Backing up customData for all resource types.
  • Upgrading dependencies.

0.0.3: 06-19-2014

  • Making application export include directory name for clarity.

0.0.2: 06-08-2014

  • Fixing bug with groups.
  • Adding support for custom data exporting.
  • Including new Stormpath SDK.

0.0.1: 12-14-2013

  • First super-beta release of the project. WOO.

stormpath-export's People

Contributors

rdegges avatar brentstormpath avatar

Stargazers

Sai Maddali avatar Michele Degges avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

stormpath-export's Issues

Provide support for restoring backed up data

One of the stated purposes of stormpath-export in its README is:

  • Back up your user data

Usually when you back up data you also want to be able to restore it, i.e. re-import it.

Currently the JSON produced by stormpath-export is essentially what you get from the list calls like:

curl -u $API_KEY_ID:$API_KEY_SECRET \
     -H "Accept: application/json" \
     "https://api.stormpath.com/v1/tenants/$TENANT_ID/directories"

However it's not suitable for restoring data following an issue (e.g. you wrote some code that accidentally deleted all your users rather than just one). I.e. the JSON is not suitable for e.g. doing:

curl -X POST -u $API_KEY_ID:$API_KEY_SECRET \
    -H "Accept: application/json" \
    -H "Content-Type: application/json"
    --data @stormpath-exports/1yHawt280jqGyvHSbmGAXK/directories/1yozsKVqI1VWZPC81oGjxS.json
    https://api.stormpath.com/v1/directories

Unsurprisingly trying this results in "developerMessage":"Property name 'createdAt' is invalid. Property names may not equal any of the following reserved names: 'href', 'createdAt', 'modifiedAt', meta', 'spMeta', 'spmeta', 'ionmeta', or 'ionMeta'." (actually you have to knock out the "provider" block before it'll start complaining about reserved names).

There are also circular dependencies between the various JSON files, e.g. JSON files for directories refer to groups while JSON files for groups refer to directories (and accounts).

So even if you knock out createdAt and other reserved names you can't restore your complete state, starting from a bare tenant, by rePOSTing these files one at a time.

In short you can export but being able to import would be nice too.

Error, No builtins

from builtins import input
ImportError: No module named builtins

when I run stormpath-export configure

python2.7

Should just install for current user (messing with system python won't work on OSX)

Just:

pip install --user stormpath-export

Trying to install it globally tries to update shutil which messes with System Integrity Protection on OS X:

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-xnyHEq-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

Disabling System Integrity Protection is bad. Just install it per-user.

ValueError Bug

I saw this bug during testing that springs up on line 171 when setting the type of the default account store mapping:

'type': application.default_account_store_mapping.account_store.__class__.__name__

=== Exporting all application data...
- Exporting application: ADFS Tester
Traceback (most recent call last):
  File "stormpath-export.py", line 610, in <module>
    main()
  File "stormpath-export.py", line 606, in main
    exporter.export(arguments['<location>'])
  File "stormpath-export.py", line 545, in export
    getattr(self, 'export_' + export_type)()
  File "stormpath-export.py", line 171, in export_applications
    'type': application.default_account_store_mapping.account_store.__class__.__name__,
  File "/usr/local/lib/python2.7/site-packages/stormpath/resources/base.py", line 129, in __getattr__
    self._ensure_data()
  File "/usr/local/lib/python2.7/site-packages/stormpath/resources/base.py", line 273, in _ensure_data
    self._set_properties(data, overwrite=overwrite)
  File "/usr/local/lib/python2.7/site-packages/stormpath/resources/base.py", line 177, in _set_properties
    value = self._wrap_resource_attr(resource_attrs[name], value)
  File "/usr/local/lib/python2.7/site-packages/stormpath/resources/base.py", line 144, in _wrap_resource_attr
    return cls(self._client, properties=value)
  File "/usr/local/lib/python2.7/site-packages/stormpath/resources/account_store.py", line 30, in AccountStore
    href)
ValueError: AccountStore called for non-account store href directories/$DIRECTORY_ID

Unicode characters

It seems like the script breaks on non-ascii characters with the following stacktrace:

Traceback (most recent call last):
  File "/usr/local/bin/stormpath-export", line 609, in <module>
    main()
  File "/usr/local/bin/stormpath-export", line 605, in main
    exporter.export(arguments['<location>'])
  File "/usr/local/bin/stormpath-export", line 546, in export
    getattr(self, 'export_' + export_type)()
  File "/usr/local/bin/stormpath-export", line 455, in export_groups
    for account in group.accounts:
  File "/usr/local/lib/python2.7/site-packages/stormpath/resources/base.py", line 425, in __iter__
    self._ensure_data()
  File "/usr/local/lib/python2.7/site-packages/stormpath/resources/base.py", line 272, in _ensure_data
    data = self._store.get_resource(self.href, params=params)
  File "/usr/local/lib/python2.7/site-packages/stormpath/data_store.py", line 190, in get_resource
    data = self.executor.get(href, params=params)
  File "/usr/local/lib/python2.7/site-packages/stormpath/http.py", line 184, in get
    return self.request('GET', url, params=params)
  File "/usr/local/lib/python2.7/site-packages/stormpath/http.py", line 164, in request
    method, url, repr(params), repr(data), repr(headers), r.status_code, r.text
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 288: ordinal not in range(128)

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.