summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md65
-rw-r--r--Readme.md24
-rw-r--r--app/controllers/application_controller.rb7
-rw-r--r--app/views/home/index.html.haml2
-rw-r--r--app/views/layouts/_navigation.html.haml12
-rw-r--r--config/deploy.rb37
-rw-r--r--public/config/eip-service.json14
m---------users/app/assets/javascripts/srp0
-rw-r--r--users/app/assets/javascripts/users.js.coffee3
-rw-r--r--users/app/controllers/application_controller.rb14
-rw-r--r--users/app/controllers/controller_extension/authentication.rb17
-rw-r--r--users/app/models/user.rb5
-rw-r--r--users/app/views/sessions/_nav.html.haml8
-rw-r--r--users/config/initializers/add_controller_methods.rb3
14 files changed, 105 insertions, 106 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3ea47bb
--- /dev/null
+++ b/README.md
@@ -0,0 +1,65 @@
+LEAP Web
+---------------------
+
+"LEAP Web" is the web-based component of the LEAP Platform, providing the following services:
+
+* REST API for user registration.
+* Admin interface to manage users.
+* Client certificate distribution and renewal.
+* User support help tickets.
+
+This web application is written in Ruby on Rails 3, using CouchDB as the backend data store.
+
+Original code specific to this web application is licensed under the GNU Affero General Public License (version 3.0 or higher). See http://www.gnu.org/licenses/agpl-3.0.html for more information.
+
+Documentation
+---------------------------
+
+For more information, see these files in the ``doc`` directory:
+
+* DEPLOY -- for notes on deployment.
+* DEVELOP -- for developer notes.
+* CUSTOM -- how to customize.
+
+Installation
+---------------------------
+
+Typically, this application is installed automatically as part of the LEAP Platform. To install it manually for testing or development, follow these instructions:
+
+### Install system requirements
+
+ sudo apt-get install git ruby1.8 rubygems1.8 couchdb
+ sudo gem bundler
+
+On Debian Wheezy or later, there is a Debian package for bundler, so you can alternately run ``sudo apt-get install bundler``.
+
+### Download source
+
+ git clone git://leap.se/leap_web
+ cd leap_web
+ git submodule update --init
+
+### Install required ruby libraries
+
+ cd leap_web
+ bundle
+
+Typically, you run ``bundle`` as a normal user and it will ask you for a sudo password when it is time to install the required gems. If you don't have sudo, run ``bundle`` as root.
+
+Configuration
+----------------------------
+
+The webapp can hand out certs for the EIP client. These certs are either picked from a pool in CouchDB or from a file. For now you can either run [Leap CA](http://github.com/leapcode/leap_ca) to fill the pool or you can put your certs file in config/cert.
+
+We also ship provider information through the webapp. For now please add your eip-service.json to the public/config directory.
+
+Running
+-----------------------------
+
+ cd leap_web
+ rails server
+
+Then open http://localhost:3000 in your web browser.
+
+To peruse the database, visit http://localhost:5984/_utils/
+
diff --git a/Readme.md b/Readme.md
deleted file mode 100644
index 8b51b4d..0000000
--- a/Readme.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Leap Web #
-
-Web application for LEAP. Currently Leap Web allows Leap providers to manage users, hand out certs for the EIP.
-
-## Functions ##
-
-### Supported ###
-
-* *User Management* - User Registration and Authentication
-* *Cert Distribution* - Certs for the Encrypted Internet Proxy
-
-### Under Development ###
-
-* *Help Desk* - Managing Help Requests
-
-
-## Documentation ##
-
-* [INSTALL](https://github.com/leapcode/leap_web/blob/master/INSTALL.md) for installation instructions
-* [DEPLOY](https://github.com/leapcode/leap_web/blob/master/DEPLOY.md) for deployment
-* [DEVELOP](https://github.com/leapcode/leap_web/blob/master/DEVELOP.md) for developer notes.
-* [CUSTOM](https://github.com/leapcode/leap_web/blob/master/CUSTOM.md) to customize.
-
-
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 693bd86..be7aa1f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,10 +1,5 @@
class ApplicationController < ActionController::Base
protect_from_forgery
- helper_method :current_user
-
- private
- def current_user
- @current_user ||= User.find(session[:user_id]) if session[:user_id]
- end
+ ActiveSupport.run_load_hooks(:application_controller, self)
end
diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml
index 34fb201..9e68674 100644
--- a/app/views/home/index.html.haml
+++ b/app/views/home/index.html.haml
@@ -8,4 +8,4 @@ Try to create a
%p
See all
-= link_to "tickets", tickets_path \ No newline at end of file
+= link_to "tickets", tickets_path
diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml
index 04d2356..b75eed7 100644
--- a/app/views/layouts/_navigation.html.haml
+++ b/app/views/layouts/_navigation.html.haml
@@ -1,10 +1,6 @@
= link_to "Leap Web", root_path, :class => 'brand'
%ul.nav
- - if current_user
- %li
- = link_to t(:logout), logout_path
- - else
- %li
- = link_to t(:login), login_path
- %li
- = link_to t(:signup), signup_path
+ // = render '/tickets/nav'
+
+%ul.nav.pull-right
+ = render '/sessions/nav'
diff --git a/config/deploy.rb b/config/deploy.rb
deleted file mode 100644
index 9dc058a..0000000
--- a/config/deploy.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require "bundler/capistrano"
-
-set :application, "webapp"
-
-set :scm, :git
-set :repository, "git://leap.se/leap_web"
-set :branch, "deploy"
-
-set :deploy_via, :remote_cache
-set :deploy_to, '/home/webapp'
-set :use_sudo, false
-
-set :normalize_asset_timestamps, false
-
-set :user, "webapp"
-
-set :git_enable_submodules, 1 # we're using an srp js submodule for now
-
-role :web, "94.103.43.3" # Your HTTP server, Apache/etc
-role :app, "94.103.43.3" # This may be the same as your `Web` server
-# role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
-# role :db, "your slave db-server here"
-
-# if you want to clean up old releases on each deploy uncomment this:
-# after "deploy:restart", "deploy:cleanup"
-
-# if you're still using the script/reaper helper you will need
-# these http://github.com/rails/irs_process_scripts
-
-# If you are using Passenger mod_rails uncomment this:
-# namespace :deploy do
-# task :start do ; end
-# task :stop do ; end
-# task :restart, :roles => :app, :except => { :no_release => true } do
-# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
-# end
-# end
diff --git a/public/config/eip-service.json b/public/config/eip-service.json
deleted file mode 100644
index 29959d7..0000000
--- a/public/config/eip-service.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "serial": 1,
- "version": "0.1.0",
- "capabilities": {
- "transport": ["openvpn"],
- "ports": ["80","53", "443", "1194"],
- "protocols": ["udp"],
- "static_ips": false,
- "adblock": false
- },
- "gateways": [
- {"country_code": "tr", "name": "turkey", "label": {"en":"Ankara, Turkey"}, "capabilities": {}, "hosts": ["94.103.43.4"]}
- ]
-}
diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp
-Subproject 5a0ceeb1ca0055719a9b8977a79936216395576
+Subproject 23350b54ec2723e1b2e333626567c9fe9d1e264
diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee
index 1c00663..24302fe 100644
--- a/users/app/assets/javascripts/users.js.coffee
+++ b/users/app/assets/javascripts/users.js.coffee
@@ -27,7 +27,8 @@ validate_password = (event) ->
signup = (event) ->
srp = new SRP(jqueryRest())
- srp.register()
+ srp.register ->
+ window.location = '/'
false
login = (event) ->
diff --git a/users/app/controllers/application_controller.rb b/users/app/controllers/application_controller.rb
deleted file mode 100644
index 64e1a55..0000000
--- a/users/app/controllers/application_controller.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class ApplicationController < ActionController::Base
- protect_from_forgery
-
- private
-
- def current_user
- @current_user ||= User.find(session[:user_id]) if session[:user_id]
- end
- helper_method :current_user
-
- def authorize
- redirect_to login_url, alert: "Not authorized" if current_user.nil?
- end
-end
diff --git a/users/app/controllers/controller_extension/authentication.rb b/users/app/controllers/controller_extension/authentication.rb
new file mode 100644
index 0000000..507b62f
--- /dev/null
+++ b/users/app/controllers/controller_extension/authentication.rb
@@ -0,0 +1,17 @@
+module ControllerExtension::Authentication
+ extend ActiveSupport::Concern
+
+ private
+
+ included do
+ helper_method :current_user
+ end
+
+ def current_user
+ @current_user ||= User.find(session[:user_id]) if session[:user_id]
+ end
+
+ def authorize
+ redirect_to login_url, :alert => "Not authorized" if current_user.nil?
+ end
+end
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index 29c0b38..a06893f 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -44,7 +44,10 @@ class User < CouchRest::Model::Base
end
def to_json(options={})
- super(options.merge(:only => ['login', 'password_salt']))
+ {
+ :login => login,
+ :ok => valid?
+ }.to_json(options)
end
def initialize_auth(aa)
diff --git a/users/app/views/sessions/_nav.html.haml b/users/app/views/sessions/_nav.html.haml
new file mode 100644
index 0000000..a5397bd
--- /dev/null
+++ b/users/app/views/sessions/_nav.html.haml
@@ -0,0 +1,8 @@
+- if current_user
+ %li
+ = link_to t(:logout), logout_path
+- else
+ %li
+ = link_to t(:login), login_path
+ %li
+ = link_to t(:signup), signup_path
diff --git a/users/config/initializers/add_controller_methods.rb b/users/config/initializers/add_controller_methods.rb
new file mode 100644
index 0000000..2579176
--- /dev/null
+++ b/users/config/initializers/add_controller_methods.rb
@@ -0,0 +1,3 @@
+ActiveSupport.on_load(:application_controller) do
+ include ControllerExtension::Authentication
+end