helpers
check_ldap_password(cn, password)
¶
Checks that the given cn/password credentials work on the given CN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cn
|
Common name to log on |
required | |
password
|
Password for cn |
required |
Returns:
| Type | Description |
|---|---|
|
True on success, False on failure |
Source code in ckanext/ldap/routes/_helpers.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
ckan_user_exists(user_name)
¶
Check if a CKAN user name exists, and if that user is an LDAP user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_name
|
User name to check |
required |
Returns:
| Type | Description |
|---|---|
|
Dictionary defining 'exists' and 'ldap'. |
Source code in ckanext/ldap/routes/_helpers.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
get_or_create_ldap_user(ldap_user_dict)
¶
Get or create a CKAN user from the data returned by the LDAP server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ldap_user_dict
|
Dictionary as returned by _find_ldap_user |
required |
Returns:
| Type | Description |
|---|---|
|
The CKAN username of an existing user |
Source code in ckanext/ldap/routes/_helpers.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
get_unique_user_name(base_name)
¶
Create a unique, valid, non existent user name from the given base name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_name
|
Base name |
required |
Returns:
| Type | Description |
|---|---|
|
A valid user name not currently in use based on base_name |
Source code in ckanext/ldap/routes/_helpers.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
get_user_dict(user_id)
¶
Calls the action API to get the detail for a user given their id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
The user id |
required |
Source code in ckanext/ldap/routes/_helpers.py
100 101 102 103 104 105 106 107 108 | |
login_failed(notice=None, error=None)
¶
Handle login failures. Redirect to /user/login and flash an optional message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notice
|
Optional notice for the user (Default value = None) |
None
|
|
error
|
Optional error message for the user (Default value = None) |
None
|
Source code in ckanext/ldap/routes/_helpers.py
23 24 25 26 27 28 29 30 31 32 33 34 | |
login_success(user_name, came_from)
¶
Handle login success. Behavior depends on CKAN version.
The CKAN version is tested via ckan.plugins.toolkit.check_ckan_version().
CKAN < 2.10.0: Saves user_name in the session under the 'ckanext-ldap-user' key, then redirects to /user/logged_in.
CKAN 2.10.0+: Looks up the CKAN User object and invokes the login_user() command (new in CKAN 2.10.0) to authenticate the user with flask-login. If that succeeds, then this saves user_name in the session under the 'ckanext-ldap-user' key before redirecting to /home/index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_name
|
The user name |
required | |
came_from
|
The value of the 'came_from' parameter sent with the original login request |
required |
Source code in ckanext/ldap/routes/_helpers.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |