foreman_cfssl 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/config/routes.rb ADDED
@@ -0,0 +1,9 @@
1
+ Rails.application.routes.draw do
2
+ get '/certs', to: 'foreman_cfssl/certs#index', as: :index
3
+ get '/certs/import', to: 'foreman_cfssl/certs#import', as: :import
4
+ post '/certs/import', to: 'foreman_cfssl/certs#import_save'
5
+ get '/certs/new', to: 'foreman_cfssl/certs#new'
6
+ post '/certs', to: 'foreman_cfssl/certs#create'
7
+ get '/certs/:id', to: 'foreman_cfssl/certs#show', as: :foreman_cfssl_cert # for easier link_to
8
+ delete '/certs/:id', to: 'foreman_cfssl/certs#destroy'
9
+ end
data/db/certs.sql ADDED
@@ -0,0 +1,21 @@
1
+ create table certs (
2
+ id serial primary key,
3
+ user_id integer,
4
+ owner_email varchar(255),
5
+ imported_at timestamp,
6
+ profile varchar(255),
7
+ subject text,
8
+ issuer text,
9
+ serial_number varchar(255),
10
+ sans text,
11
+ not_before timestamp,
12
+ not_after timestamp,
13
+ sigalg varchar(255),
14
+ authority_key_id varchar(255),
15
+ subject_key_id varchar(255),
16
+ pem text not null,
17
+ key text
18
+ );
19
+
20
+ create index index_certs_owner_email on certs (owner_email);
21
+ create index index_certs_not_after on certs (not_after);
@@ -0,0 +1,21 @@
1
+ class CreateCerts < ActiveRecord::Migration
2
+ def change
3
+ create_table :certs do |t|
4
+ t.integer :user_id
5
+ t.string :owner_email, limit: 64, index: true
6
+ t.timestamp :imported_at
7
+ t.string :profile, limit: 16
8
+ t.text :subject
9
+ t.text :issuer
10
+ t.string :serial_number, limit: 255
11
+ t.text :sans
12
+ t.timestamp :not_before
13
+ t.timestamp :not_after, index: true
14
+ t.string :sigalg, limit: 16
15
+ t.string :authority_key_id, limit: 255
16
+ t.string :subject_key_id, limit: 255
17
+ t.text :pem, null: false
18
+ t.text :key
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ require 'foreman_cfssl/engine'
2
+
3
+ module ForemanCfssl
4
+ end
@@ -0,0 +1,64 @@
1
+ module ForemanCfssl
2
+ class Engine < ::Rails::Engine
3
+ engine_name 'foreman_cfssl'
4
+
5
+ config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
6
+ config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
7
+ config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
8
+ config.autoload_paths += Dir["#{config.root}/app/overrides"]
9
+
10
+ # Add any db migrations
11
+ initializer 'foreman_cfssl.load_app_instance_data' do |app|
12
+ ForemanCfssl::Engine.paths['db/migrate'].existent.each do |path|
13
+ app.config.paths['db/migrate'] << path
14
+ end
15
+ end
16
+
17
+ initializer 'foreman_cfssl.register_plugin', :before => :finisher_hook do |_app|
18
+ Foreman::Plugin.register :foreman_cfssl do
19
+ requires_foreman '>= 1.4'
20
+
21
+ # Add permissions
22
+ security_block :foreman_cfssl do
23
+ permission :admin_foreman_cfssl, :'foreman_cfssl/certs' => [
24
+ :index, :import, :import_save, :new, :create, :show, :destroy]
25
+ end
26
+
27
+ # Add a new role
28
+ role 'CFSSL', [:admin_foreman_cfssl]
29
+
30
+ # add menu entry
31
+ menu :top_menu, :template,
32
+ url_hash: { controller: :'foreman_cfssl/certs', action: :index },
33
+ caption: 'Certificates',
34
+ parent: :infrastructure_menu,
35
+ after: :smart_proxies
36
+
37
+ # add dashboard widget
38
+ #widget 'foreman_cfssl_widget', name: 'Foreman CFSSL', sizex: 4, sizey: 1
39
+ end
40
+ end
41
+
42
+ # Precompile any JS or CSS files under app/assets/
43
+ # If requiring files from each other, list them explicitly here to avoid precompiling the same
44
+ # content twice.
45
+ assets_to_precompile =
46
+ Dir.chdir(root) do
47
+ Dir['app/assets/javascripts/**/*', 'app/assets/stylesheets/**/*'].map do |f|
48
+ f.split(File::SEPARATOR, 4).last
49
+ end
50
+ end
51
+ initializer 'foreman_cfssl.assets.precompile' do |app|
52
+ app.config.assets.precompile += assets_to_precompile
53
+ end
54
+ initializer 'foreman_cfssl.configure_assets', group: :assets do
55
+ SETTINGS[:foreman_cfssl] = { assets: { precompile: assets_to_precompile } }
56
+ end
57
+
58
+ rake_tasks do
59
+ Rake::Task['db:seed'].enhance do
60
+ ForemanCfssl::Engine.load_seed
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,3 @@
1
+ module ForemanCfssl
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,47 @@
1
+ require 'rake/testtask'
2
+
3
+ # Tasks
4
+ namespace :foreman_cfssl do
5
+ namespace :example do
6
+ desc 'Example Task'
7
+ task task: :environment do
8
+ # Task goes here
9
+ end
10
+ end
11
+ end
12
+
13
+ # Tests
14
+ namespace :test do
15
+ desc 'Test ForemanCfssl'
16
+ Rake::TestTask.new(:foreman_cfssl) do |t|
17
+ test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
18
+ t.libs << ['test', test_dir]
19
+ t.pattern = "#{test_dir}/**/*_test.rb"
20
+ t.verbose = true
21
+ t.warning = false
22
+ end
23
+ end
24
+
25
+ namespace :foreman_cfssl do
26
+ task :rubocop do
27
+ begin
28
+ require 'rubocop/rake_task'
29
+ RuboCop::RakeTask.new(:rubocop_foreman_cfssl) do |task|
30
+ task.patterns = ["#{ForemanCfssl::Engine.root}/app/**/*.rb",
31
+ "#{ForemanCfssl::Engine.root}/lib/**/*.rb",
32
+ "#{ForemanCfssl::Engine.root}/test/**/*.rb"]
33
+ end
34
+ rescue
35
+ puts 'Rubocop not loaded.'
36
+ end
37
+
38
+ Rake::Task['rubocop_foreman_cfssl'].invoke
39
+ end
40
+ end
41
+
42
+ Rake::Task[:test].enhance ['test:foreman_cfssl']
43
+
44
+ load 'tasks/jenkins.rake'
45
+ if Rake::Task.task_defined?(:'jenkins:unit')
46
+ Rake::Task['jenkins:unit'].enhance ['test:foreman_cfssl', 'foreman_cfssl:rubocop']
47
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman_cfssl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Qingbo Zhou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A Foreman plugin that uses CFSSL to generate certificates
42
+ email:
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - LICENSE
48
+ - README.md
49
+ - Rakefile
50
+ - app/controllers/foreman_cfssl/certs_controller.rb
51
+ - app/models/concerns/foreman_cfssl/cert.rb
52
+ - app/views/dashboard/_foreman_cfssl_widget.html.erb
53
+ - app/views/foreman_cfssl/certs/import.html.erb
54
+ - app/views/foreman_cfssl/certs/index.html.erb
55
+ - app/views/foreman_cfssl/certs/new.html.erb
56
+ - app/views/foreman_cfssl/certs/show.html.erb
57
+ - config/routes.rb
58
+ - db/certs.sql
59
+ - db/migrate/20170801221500_create_certs.rb
60
+ - lib/foreman_cfssl.rb
61
+ - lib/foreman_cfssl/engine.rb
62
+ - lib/foreman_cfssl/version.rb
63
+ - lib/tasks/foreman_cfssl_tasks.rake
64
+ homepage: http://thinlight.org/
65
+ licenses:
66
+ - GPL-3.0
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.6.11
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Foreman CFSSL plugin
88
+ test_files: []