Permalink
Browse files

add: testpage for http-basic-auth

  • Loading branch information...
1 parent 4c27984 commit debf93ff8ea2ea773f6857a1023bb8cf08029b19 Sven Krzyzak committed May 15, 2011
Showing with 18 additions and 0 deletions.
  1. +16 −0 app/controllers/mylyn_connector/information_controller.rb
  2. +2 −0 config/routes.rb
@@ -24,4 +24,20 @@ def token
render :text => form_authenticity_token
end
+
+ def authtest
+
+ authenticate_with_http_basic do |username, password|
+ if user = User.try_to_login(username, password)
+ txt = 'Hello ' + user.name + ' - your HTTP-Basic-Authentication does work properly.'
+ txt += ' <b>But you have to enable the Rest-API!</b>' unless Setting.rest_api_enabled?;
+
+ render :text => txt
+ return
+ end
+ end
+
+ head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"'
+
+ end
end
View
@@ -31,4 +31,6 @@
rmc.connect 'mylyn/attachment/:id/:filename', :controller => 'attachments', :action => 'download', :format=> 'xml', :id => /\d+/, :filename => /.*/
end
+ map.connect 'mylyn/authtest', :controller => 'MylynConnector::Information', :action => 'authtest', :conditions => {:method => :get}
+
end

0 comments on commit debf93f

Please sign in to comment.