Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First commit

  • Loading branch information...
commit 85d43826b59539ab4aa8a6c11aa3022c7ff28c47 0 parents
@divineforest authored
4 .gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
4 Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in komandir.gemspec
+gemspec
1  Rakefile
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
24 komandir.gemspec
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "komandir/version"
+
+Gem::Specification.new do |s|
+ s.name = "komandir"
+ s.version = Komandir::VERSION
+ s.authors = ["divineforest"]
+ # s.email = [""]
+ s.homepage = ""
+ s.summary = %q{TODO: Write a gem summary}
+ s.description = %q{TODO: Write a gem description}
+
+ s.rubyforge_project = "komandir"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ # s.add_development_dependency "rspec"
+ # s.add_runtime_dependency "rest-client"
+end
5 lib/komandir.rb
@@ -0,0 +1,5 @@
+require "komandir/version"
+require "komandir/railtie"
+
+module Komandir
+end
28 lib/komandir/action_controller.rb
@@ -0,0 +1,28 @@
+module Komandir
+ module ControllerMethods
+
+ module ClassMethods
+ end
+
+ module InstanceMethods
+ def action_signature_valid?(user)
+ raise "Blank komandir_random_text" if params[:komandir_random_text].blank?
+ raise "Blank komandir_signature" if params[:komandir_signature].blank?
+ raise "Blank certificate for user. Make sure user.certificate.body contains certificate" unless user.certificate.try(:body?)
+
+ verification_set = {
+ :message => params[:komandir_random_text],
+ :signature => params[:komandir_signature],
+ :certificate => user.certificate.body
+ }
+ Cryptopro::Signature.verify(verification_set)
+ end
+ end
+
+ def self.included(receiver) # :nodoc:
+ receiver.extend ClassMethods
+ receiver.send :include, InstanceMethods
+ end
+
+ end
+end
8 lib/komandir/railtie.rb
@@ -0,0 +1,8 @@
+module Komandir
+ class Railtie < Rails::Railtie
+ initializer "komandir.action_controller" do |app|
+ require 'komandir/action_controller'
+ ActionController::Base.send :include, Komandir::ControllerMethods
+ end
+ end
+end
3  lib/komandir/version.rb
@@ -0,0 +1,3 @@
+module Komandir
+ VERSION = "0.0.1"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.