Commit d422e8b9 authored by Ryan Lee's avatar Ryan Lee

initial test of LDAP account creation via POST of username

parents
OpenProject LDAP Account Creation
=================================
Provides a new API point for requesting the creation of an account originating
from an LDAP AuthSource.
Usage
=====
```
POST /.../?username=new_login
```
class ZepheiraController < ApplicationController
def ldap
if request.post?
login = params[:username]
user = nil
auth_sources = AuthSource.find(:all)
auth_sources.each do |src|
if src.auth_method_name == 'LDAP'
user_dn = src.get_user_dn(login)
if user_dn
attrs = src.get_user_attributes_from_ldap_entry(user_dn)
user = User.new(attrs.except(:dn).except(:login))
user.login = login
user.language = Setting.default_language
if user.save
logger.info("User '#{user.login}' created from #{user.auth_source.name} by API") if logger && user.auth_source
end
end
end
end
if user.nil?
render_404
else
render :nothing => true, :status => 200
end
else
render_404
end
end
end
module OpenProject
module CreateLdapAccount
require 'open_project/create_ldap_account/engine'
end
end
require 'open_project/plugins'
module OpenProject::CreateLdapAccount
class Engine < ::Rails::Engine
engine_name :openproject_create_ldap_account
include OpenProject::Plugins::ActsAsOpEngine
register 'openproject-create_ldap_account',
:author_url => 'http://zepheira.com/',
:requires_openproject => '>= 3.0.0' do
Redmine::AccessControl.permission(:create_ldap_account, { :controller => "zepheira", :action => "ldap" }, { :public => true })
end
end
end
module OpenProject
module CreateLdapAccount
VERSION = "1.0.0"
end
end
require 'open_project/create_ldap_account'
# -*- encoding: utf-8 -*-
# stub: openproject-create_ldap_account 1.0.0 ruby lib
Gem::Specification.new do |s|
s.name = "openproject-create_ldap_account"
s.version = "3.0.8"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Ryan Lee", "Zepheira LLC"]
s.date = "2014-11-10"
s.description = "Provides a new API point for requesting the creation of an account."
s.email = "ryanlee@zepheira.com"
s.files = ["README.md", "lib/openproject-create_ldap_account.rb", "lib/open_project/create_ldap_account.rb", "lib/open_project/create_ldap_account/engine.rb"]
s.homepage = "http://zepheira.com"
s.licenses = ["BSD"]
s.rubygems_version = "2.2.2"
s.summary = "OpenProject LDAP Account Creation"
s.test_files = []
if s.respond_to? :specification_version then
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rails>, ["~> 3.2.9"])
s.add_runtime_dependency(%q<openproject-plugins>, ["~> 3.0.8"])
else
s.add_dependency(%q<rails>, ["~> 3.2.9"])
s.add_dependency(%q<openproject-plugins>, ["~> 3.0.8"])
end
else
s.add_dependency(%q<rails>, ["~> 3.2.9"])
s.add_dependency(%q<openproject-plugins>, ["~> 3.0.8"])
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment