Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
  • Loading branch information
lgromanowski committed Dec 6, 2015
1 parent 7625a5e commit d80d025
Show file tree
Hide file tree
Showing 68 changed files with 1,166 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
@@ -0,0 +1,8 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/db/*.sqlite3-journal
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache
15 changes: 15 additions & 0 deletions Gemfile
@@ -0,0 +1,15 @@
source 'https://rubygems.org'

# Declare your gem's dependencies in letsencrypt_plugin.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use a debugger
# gem 'byebug', group: [:development, :test]

127 changes: 127 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,127 @@
PATH
remote: .
specs:
letsencrypt_plugin (0.0.1)
acme-client
rails (~> 4.2.5)
sqlite3

GEM
remote: https://rubygems.org/
specs:
acme-client (0.2.0)
faraday (~> 0.9, >= 0.9.1)
json-jwt (~> 1.2, >= 1.2.3)
url_safe_base64 (~> 0.2, >= 0.2.2)
actionmailer (4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5)
actionview (= 4.2.5)
activesupport (= 4.2.5)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5)
activesupport (= 4.2.5)
globalid (>= 0.3.0)
activemodel (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
activerecord (4.2.5)
activemodel (= 4.2.5)
activesupport (= 4.2.5)
arel (~> 6.0)
activesupport (4.2.5)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
bindata (2.1.0)
builder (3.2.2)
concurrent-ruby (1.0.0)
erubis (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
json (1.8.3)
json-jwt (1.5.1)
activesupport
bindata
multi_json (>= 1.3)
securecompare
url_safe_base64
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.99)
mini_portile2 (2.0.0)
minitest (5.8.3)
multi_json (1.11.2)
multipart-post (2.0.0)
nokogiri (1.6.7)
mini_portile2 (~> 2.0.0.rc2)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5)
actionmailer (= 4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
activemodel (= 4.2.5)
activerecord (= 4.2.5)
activesupport (= 4.2.5)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.5)
actionpack (= 4.2.5)
activesupport (= 4.2.5)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
securecompare (1.0.0)
sprockets (3.5.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.11)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
url_safe_base64 (0.2.2)

PLATFORMS
ruby

DEPENDENCIES
letsencrypt_plugin!
minitest
20 changes: 20 additions & 0 deletions MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright 2015 lgromanowski

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 changes: 37 additions & 0 deletions Rakefile
@@ -0,0 +1,37 @@
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

require 'rdoc/task'

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'LetsencryptPlugin'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'


load 'rails/tasks/statistics.rake'



Bundler::GemHelper.install_tasks

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end


task default: :test
Empty file.
13 changes: 13 additions & 0 deletions app/assets/javascripts/letsencrypt_plugin/application.js
@@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .
15 changes: 15 additions & 0 deletions app/assets/stylesheets/letsencrypt_plugin/application.css
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
22 changes: 22 additions & 0 deletions app/controllers/letsencrypt_plugin/application_controller.rb
@@ -0,0 +1,22 @@
module LetsencryptPlugin
class ApplicationController < ActionController::Base
before_action :validate_length, only: [:index]

def index
# There is only one item in DB with challenge response from our task
# we will use it to render plain text response
@response = Challenge.first
render plain: @response.response
end

private
def validate_length
# Challenge request should have at least 128bit
challenge_failed if params[:challenge].nil? || params[:challenge].length < 16 || params[:challenge].length > 256
end

def challenge_failed
raise ActionController::RoutingError.new('Challenge failed - invalid request.')
end
end
end
4 changes: 4 additions & 0 deletions app/helpers/letsencrypt_plugin/application_helper.rb
@@ -0,0 +1,4 @@
module LetsencryptPlugin
module ApplicationHelper
end
end
4 changes: 4 additions & 0 deletions app/models/letsencrypt_plugin/challenge.rb
@@ -0,0 +1,4 @@
module LetsencryptPlugin
class Challenge < ActiveRecord::Base
end
end
1 change: 1 addition & 0 deletions app/views/layouts/letsencrypt_plugin/application.html.erb
@@ -0,0 +1 @@
<%= yield %>
12 changes: 12 additions & 0 deletions bin/rails
@@ -0,0 +1,12 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/letsencrypt_plugin/engine', __FILE__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

require 'rails/all'
require 'rails/engine/commands'
3 changes: 3 additions & 0 deletions config/initializers/letsencrypt_plugin.rb
@@ -0,0 +1,3 @@
CONFIG = YAML.load_file(Rails.root.join('config', 'letsencrypt_plugin.yml'))
CONFIG.merge! CONFIG.fetch(Rails.env, {})
CONFIG.symbolize_keys!
3 changes: 3 additions & 0 deletions config/routes.rb
@@ -0,0 +1,3 @@
LetsencryptPlugin::Engine.routes.draw do
get '.well-known/acme-challenge/:challenge' => 'application#index'
end
@@ -0,0 +1,9 @@
class CreateLetsencryptPluginChallenges < ActiveRecord::Migration
def change
create_table :letsencrypt_plugin_challenges do |t|
t.text :response

t.timestamps null: false
end
end
end
23 changes: 23 additions & 0 deletions letsencrypt_plugin.gemspec
@@ -0,0 +1,23 @@
$:.push File.expand_path("../lib", __FILE__)

# Maintain your gem's version:
require "letsencrypt_plugin/version"

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "letsencrypt_plugin"
s.version = LetsencryptPlugin::VERSION
s.authors = ["Lukasz Gromanowski"]
s.email = ["lgromanowski@gmail.com"]
s.homepage = "https://github.com/lgromanowski/letsencrypt-plugin"
s.summary = "Let's encrypt plugin for Ruby on Rails applications"
s.license = "MIT"

s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails", "~> 4.2.5"
s.add_dependency "acme-client"
s.add_dependency "sqlite3"
s.add_development_dependency "minitest"
end
4 changes: 4 additions & 0 deletions lib/letsencrypt_plugin.rb
@@ -0,0 +1,4 @@
require "letsencrypt_plugin/engine"

module LetsencryptPlugin
end
5 changes: 5 additions & 0 deletions lib/letsencrypt_plugin/engine.rb
@@ -0,0 +1,5 @@
module LetsencryptPlugin
class Engine < ::Rails::Engine
isolate_namespace LetsencryptPlugin
end
end
3 changes: 3 additions & 0 deletions lib/letsencrypt_plugin/version.rb
@@ -0,0 +1,3 @@
module LetsencryptPlugin
VERSION = "0.0.1"
end

0 comments on commit d80d025

Please sign in to comment.