Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create initial admin user with password and API key for REST API #523

Open
mloskot opened this issue Sep 24, 2020 · 0 comments
Open

Create initial admin user with password and API key for REST API #523

mloskot opened this issue Sep 24, 2020 · 0 comments

Comments

@mloskot
Copy link

mloskot commented Sep 24, 2020

Ubuntu 18.04
Package: api-umbrella
Version: 0.15.1-1~bionic

My goal is to do the following during provisioning of a server with API Umbrella setup:

  1. Initialise the service with initial/default admin user
  2. Use the REST API to pre-configure the API Umbrella with API backends and API users with keys.

From the docs, I've learned how to create the initial super

web:
  admin:
    auth_strategies:
      enabled:
        - local
    initial_superusers:
      - [email protected]
    username_is_email: true

and the user gets created but it is not usable:

  1. No password is generated and blank password is not accepted, and it is not documented if it's possible to enable it.
  2. No API key is generated to be used as the X-Api-Key: header value.
  3. Only authentication_token is created, which I assume is for use as the X-Admin-Auth-Token: header value.

The issue 1. has been also asked about in #439 (comment)

As I have learned from #368 (comment) and #439 (comment), I can query the MongoDB directly:

$ /opt/api-umbrella/embedded/bin/mongo 127.0.0.1:14001/api_umbrella --eval "db.admins.find().pretty()"
MongoDB shell version: 3.2.22
connecting to: 127.0.0.1:14001/api_umbrella
{
        "_id" : "2ff988a5-b087-4d3a-9326-c3285feb0214",
        "updated_at" : ISODate("2020-09-24T15:55:19Z"),
        "username" : "[email protected]",
        "authentication_token" : "z2S0DyE4vZDWtznq6jZAqeT4fW1hVVzTvuSZaBYf",
        "registration_source" : "seed",
        "created_at" : ISODate("2020-09-24T15:55:19Z"),
        "superuser" : true
}

In this old issue @brylie asked "How do I access my auth token and admin API key?" which is a question close to mine but @darylrobbins explained in #135 (comment) how to generate the authentication_token which apparently had not been generated in old versions of the API Umbrella due to missing implementation fixed in NREL/api-umbrella-router@fa10065

That solution does not apply to my case as my initial_superusers get the authentication_token generated.

Is there a similar mongo trick to generate the API key for X-Api-Key:?
How to create superuser non-interactively in order to pre-configure the API Umbrella service via the REST API in non-interactive manner?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant