Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit 85d43826b59539ab4aa8a6c11aa3022c7ff28c47 @divineforest committed Nov 21, 2011
Showing with 77 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +4 −0 Gemfile
  3. +1 −0 Rakefile
  4. +24 −0 komandir.gemspec
  5. +5 −0 lib/komandir.rb
  6. +28 −0 lib/komandir/action_controller.rb
  7. +8 −0 lib/komandir/railtie.rb
  8. +3 −0 lib/komandir/version.rb
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in komandir.gemspec
+gemspec
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
@@ -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
@@ -0,0 +1,5 @@
+require "komandir/version"
+require "komandir/railtie"
+
+module Komandir
+end
@@ -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
@@ -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
@@ -0,0 +1,3 @@
+module Komandir
+ VERSION = "0.0.1"
+end

0 comments on commit 85d4382

Please sign in to comment.