Git Product home page Git Product logo

api-key-dealer's Introduction

Algolia API Key Dealer

Running tests on travis can be a pain if you need credentials that shouldn't be publicly shared. This projects aims to solve that. Read the details of why and how on Algolia's blog: https://blog.algolia.com/travis-encrypted-variables-external-contributions/

NOTE: It's not exactly a framework and an app you'll be able to use right away, but it could be a good start if you want to build something similar.

Feel free to share your thoughts on this thread of the forum.

Client

Inside the client folder, you will find the go script used to call the API from your CI. Travis (in this case) will download the latest client binary and execute it to get temporary credentials.

Example of .travis.yml

before_script:
  - wget https://keys.algolia.engineering/client/algolia-keys && chmod +x algolia-keys

script:
  - $(./algolia-keys export) && php vendor/bin/phpunit

Endpoints

Host is in the Github description โ˜๏ธ

Get a key

POST /1/travis/keys/new
{
    "TRAVIS_JOB_ID": value,
}

The job ID can be found in the env variable TRAVIS_JOB_ID (it's set automatically).

Response

{
    "app-id": "I2UB5B7IZB",
    "api-key": "ee04e3...",
    "api-search-key": "0356747...",
    "places": {
        "app-id": "plSYS0QH6R4R",
        "api-key": "93d082..."
    },
    "comment": "The keys will expire after 3 minutes."
}

Debugging

Setup the repository locall and run tests

git clone https://github.com/algolia/api-key-dealer
cd api-key-dealer
composer install
cp .env.example .env

# edit to `.env` and add
# - test_ADMIN
# - NOCTT5TZUU_ADMIN
# - UCX3XB3SH4_ADMIN
# - CTS_1_ADMIN_KEY
# - CTS_2_ADMIN_KEY
    
# Run tests
composer test

Call local API

If you want to test it locally, set the DEALER_HOST environment variable to the host of your local server.

Typically, you run the server with:

php -S localhost:8080 -t public

And test the client with:

eval $(DEALER_HOST=localhost:8080./public/clients/algolia-keys-mac export)

Force repository name

If you want to test the configuration for a give repository, you can pass a repository-name parameter. It will only be taken into account if your call the API locally or from Algolia's office. It will bypass the call to Travis API.

POST /1/algolia/keys/new
{
    "repository-name": "algolia/algoliasearch-client-php",
}

api-key-dealer's People

Contributors

bsuravech avatar chloelbn avatar devincodes avatar julienbourdeau avatar nunomaduro avatar rayrutjes avatar tomklotzpro avatar

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.