Skip to content

Commit

Permalink
Merge pull request #15 from shackit/master
Browse files Browse the repository at this point in the history
Adds reconnect logic to kube-ldap client
  • Loading branch information
juckerf authored Jul 19, 2018
2 parents f4b65ea + 9a2aae4 commit 905f826
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ List of configurable values:
|`config.ldap.baseDn`|Base DN for LDAP search|`LDAP_BASEDN`|dc=example,dc=com|
|`config.ldap.filter`|Filter for LDAP search|`LDAP_FILTER`|(uid=%s)|
|`config.ldap.timeout`|Timeout for LDAP connections & operations (in seconds)|`LDAP_TIMEOUT`|0 (infinite for operations, OS default for connections)|
|`config.ldap.reconnectInitialDelay`|Seconds to wait before reconnecting|`LDAP_RECONN_INIT_DELAY`|100|
|`config.ldap.reconnectMaxDelay`|Maximum seconds to wait before reconnecting|`LDAP_RECONN_MAX_DELAY`|1000|
|`config.ldap.reconnectFailAfter`|Fail after number of retries|`LDAP_RECONN_FAIL_AFTER`|10|
|`config.mapping.username`|Name of ldap attribute to be used as username in kubernetes TokenReview|`MAPPING_USERNAME`|uid|
|`config.mapping.uid`|Name of ldap attribute to be used as uid in kubernetes TokenReview|`MAPPING_UID`|uid|
|`config.mapping.groups`|Name of ldap attribute to be used for groups in kubernetes TokenReview|`MAPPING_GROUPS`|memberOf|
Expand Down
5 changes: 5 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ let ldapClient = new Client(
url: config.ldap.uri,
timeout: config.ldap.timeout * 1000,
connectTimeout: config.ldap.timeout * 1000,
reconnect: {
initialDelay: config.ldap.reconnectInitialDelay,
maxDelay: config.ldap.reconnectMaxDelay,
failAfter: config.ldap.reconnectFailAfter
}
}),
config.ldap.baseDn,
config.ldap.bindDn,
Expand Down
3 changes: 3 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const getConfig = () => {
baseDn: process.env.LDAP_BASEDN || 'dc=example,dc=com',
filter: process.env.LDAP_FILTER || '(uid=%s)',
timeout: parseInt(process.env.LDAP_TIMEOUT) || 0,
reconnectInitialDelay: parseInt(process.env.LDAP_RECONN_INIT_DELAY) || 100,
reconnectMaxDelay: parseInt(process.env.LDAP_RECONN_MAX_DELAY) || 1000,
reconnectFailAfter: parseInt(process.env.LDAP_RECONN_FAIL_AFTER) || 10,
},
mapping: {
username: process.env.MAPPING_USERNAME || 'uid',
Expand Down

0 comments on commit 905f826

Please sign in to comment.