riboseinc / rails-keyserver

A generic Rails engine for serving most kinds of keys

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rails::Keyserver

Gem Version Build Status Test Coverage Code Climate

A generic Rails engine for serving most kinds of keys.

Installation

Add this line to your application’s Gemfile:

gem 'rails-keyserver'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails-keyserver

Routes

The following is a sample of what we would like to achieve in terms of API endpoints:

# GET JSON
# /security/pgp_keys?date_from=X&date_to=Y&purpose=mail&sort_by=activation_date&order=desc
[
  {
    public: '===== BEGIN PGP BLOCK ==========.....',
    key_id: 0x346cb447
    key_type: rsa
    expires: '2055/12/12 11:23:45Z+08:00'
    key_size: 4096/4096
    fingerprint: 72e5 f8ae da12 7b85 fadb 25a5 83a3 ef8c 346c b447
    userid: apple product security
    activation_date: '2055/12/12 11:23:45Z+08:00',
  }
]

# GET JSON /security/pgp_keys
[
  {
    public: '===== BEGIN PGP BLOCK ==========.....',
    key_id: 0x346cb446
    key_type: rsa
    expires: '2055/12/12 11:23:45Z+08:00'
    key_size: 4096/4096
    fingerprint: 72e5 f8ae da12 7b85 fadb 25a5 83a3 ef8c 346c b447
    userid: apple product security
    activation_date: '2055/12/12 11:23:45Z+08:00',
  }
]

# rails users: public PGP
# DELETE  JSON /settings/pgp_key
# POST  PUT  GET JSON /settings/pgp_key
200:
{
  id: 'slfsjdfdklsj',
  public: '===== BEGIN PGP BLOCK ==========.....',
  key_id: 0x346cb446
  key_type: rsa
  expires: '2055/12/12 11:23:45Z+08:00'
  key_size: 4096/4096
  fingerprint: 72e5 f8ae da12 7b85 fadb 25a5 83a3 ef8c 346c b447
  userid: apple product security
  created_at: '2055/12/12 11:23:45Z+08:00',
}

422:
{
  errors: {
    format: 'invalid'
  }
}

403:
{
  errors: {
    permission: 'denied'
  }
}

Usage

Override controllers and rendering methods

Keys Controller

  • #render_index

    • @composed is the collection to render

  • #render_show_json(key)

  • #render_show_ext(key)

Default settings for mounted routes

# E.g. in config/routes.rb
mount_keyserver at: 'ks', controllers: {
  keys: 'rails/keyserver/api/v1/keys',
}

Contributing

First, thank you for contributing! We love pull requests from everyone. By participating in this project, you hereby grant Ribose Inc. the right to grant or transfer an unlimited number of non exclusive licenses or sub-licenses to third parties, under the copyright covering the contribution to use the contribution by all means.

Here are a few technical guidelines to follow:

  1. Open an issue to discuss a new feature.

  2. Write tests to support your new feature.

  3. Make sure the entire test suite passes locally and on CI.

  4. Open a Pull Request.

  5. After receiving feedback, perform an interactive rebase on your branch, in order to create a series of cohesive commits with descriptive messages.

  6. Party!

Credits

This gem is developed, maintained and funded by Ribose Inc.

License

The gem is available as open source under the terms of the MIT License.

About

A generic Rails engine for serving most kinds of keys

License:MIT License


Languages

Language:Ruby 83.7%Language:QMake 8.2%Language:HTML 4.1%Language:Shell 1.7%Language:JavaScript 1.2%Language:CSS 1.1%