Class: Identizer::Handlers::Directory

Inherits:
Base
  • Object
show all
Defined in:
lib/identizer/handlers/directory.rb

Overview

CRUD over the LDAP-flavoured user directory. Requires a store exposing the management interface (#entries, #upsert, #delete) — the default does.

Constant Summary collapse

BLOCKED_ATTRIBUTES =

Reserved/standard names a custom attribute must not set — otherwise it could overwrite a form field or forge a registered token claim.

(
  DirectoryEntry::EDITABLE_ATTRIBUTES +
  %w[iss aud exp iat nbf jti nonce sub email given_name family_name name groups preferred_username dn]
).map(&:downcase).freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Responses

#amz_json, #escape_html, #html, #json, #no_content, #not_found, #notice_page, #redirect, #xml

Constructor Details

This class inherits a constructor from Identizer::Handlers::Base

Instance Method Details

#create(request) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/identizer/handlers/directory.rb', line 23

def create(request)
  attributes = entry_params(request)
  # On rename (mail changed while editing), drop the old row so we don't
  # leave a duplicate behind.
  original = request.params["original_mail"].to_s
  store.delete(original) if !original.empty? && original != attributes["mail"]
  store.upsert(attributes)
  redirect("#{request.script_name}/directory")
end

#destroy(request) ⇒ Object



33
34
35
36
# File 'lib/identizer/handlers/directory.rb', line 33

def destroy(request)
  store.delete(request.params["mail"])
  redirect("#{request.script_name}/directory")
end

#index(request) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/identizer/handlers/directory.rb', line 15

def index(request)
  editing = request.params["edit"]
  page("directory/index", request, nav: :directory, title: "Directory",
                                   entries: store.entries,
                                   entry: entry_for(editing),
                                   base_dn: config.ldap_base_dn)
end