Skip to content

codedoctor/hapi-routes-tenants-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status NPM Version Dependency Status NPM Downloads Issues HAPI 8.0 API Documentation

(C) 2014 Martin Wawrusch

Provides an enpoint to set up a tenant with

  • initial users
  • oauth scopes
  • roles
  • a default oauth app + client
  • tokens for your users

Basically, this allows you to bootstrap an installation using the codedoctor libraries by providing a /tenants/setup endpoint that you can post to.

Take a look at the samples/sample.json file, which contains the typical sample data. Both tenantId and clientId are optional. The file samples/result.json shows you the result of posting the sample.json file.

How to secure this

Several easy options:

  • Only include it when you run it for the first time, then remove it.
  • supply a secret key, which must be included as the payload (secretKey). Something like so:
hapiRoutesTenantsSetup = require 'hapi-routes-tenants-setup'

...

server = new Hapi.Server config.server.port, config.server.host,serverOptions

pluginConf = [
  ...
  ,
    plugin: hapiRoutesTenantsSetup
    options:
      secretKey: process.env.HAPIROUTESTENANTSETUPSECRETKEY
]

server.pack.register pluginConf, (err) ->
  throw err if err
  ...

You then set the env variable HAPIROUTESTENANTSETUPSECRETKEY at your server.

How to post from curl

curl -H "Content-Type: application/json" -X POST -d @samples/sample.json https://yoursite.com/tenants/setup

Dependencies

  • HAPI >= 8.0.0,hapi-oauth-store-multi-tenant,hapi-user-store-multi-tenant

Plugins that must be loaded into your hapi server:

  • hapi-oauth-store-multi-tenant
  • hapi-user-store-multi-tenant

See also

and additionally

Contributing

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the package.json, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2014 Martin Wawrusch