Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gdd-sigma-poc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guillaume WANG
gdd-sigma-poc
Commits
e091580e
Commit
e091580e
authored
6 years ago
by
Quentin CHEVALIER
Browse files
Options
Downloads
Patches
Plain Diff
userData and groupData to classes, clean search, escape filter in Tools not Basics
parent
ec12c774
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ldap/internal/basics.ts
+1
-6
1 addition, 6 deletions
src/ldap/internal/basics.ts
src/ldap/internal/tools.ts
+5
-0
5 additions, 0 deletions
src/ldap/internal/tools.ts
with
6 additions
and
6 deletions
src/ldap/internal/basics.ts
+
1
−
6
View file @
e091580e
...
...
@@ -105,10 +105,6 @@ export class Basics {
if
(
domain
==
"
gr
"
)
{
dn
+=
ldapConfig
.
dn_groups
;
}
else
{
dn
+=
ldapConfig
.
dn_users
;
}
// Interrogation LDAP selon filter
console
.
log
(
dn
);
//filter = ldapEscape.filter("${txt}", { txt: filter });
console
.
log
(
filter
);
let
promise
=
new
Promise
<
void
>
(
function
(
resolve
,
reject
)
{
client
.
search
(
dn
,
{
// Must be escaped in case of a malignious false id
"
scope
"
:
"
sub
"
,
...
...
@@ -147,7 +143,7 @@ export class Basics {
*/
static
async
searchSingle
(
domain
:
'
gr
'
|
'
us
'
,
attribute
:
string
,
id
:
string
=
null
,
filter
:
string
=
"
(objectClass=*)
"
)
:
Promise
<
string
[]
>
{
let
vals
=
[];
Basics
.
search
(
domain
,
[
attribute
],
id
,
filter
,
entry
=>
{
await
Basics
.
search
(
domain
,
[
attribute
],
id
,
filter
,
entry
=>
{
// Cas un seul attribut où le résultat est une liste directement
vals
.
push
(
entry
.
object
[
attribute
]);
});
...
...
@@ -172,7 +168,6 @@ export class Basics {
let
vals
=
[];
await
Basics
.
search
(
domain
,
attributes
,
id
,
filter
,
entry
=>
{
// Cas plusieurs attributs donc résultat dictionnaire
console
.
log
(
"
Found entry!!
"
);
vals
.
push
({});
attributes
.
forEach
(
attribute
=>
{
vals
.
slice
(
-
1
)[
0
][
attribute
]
=
entry
.
object
[
attribute
];
...
...
This diff is collapsed.
Click to expand it.
src/ldap/internal/tools.ts
+
5
−
0
View file @
e091580e
...
...
@@ -3,6 +3,9 @@
* @author hawkspar
*/
// Toutes les entrées utilisateur sont escapées par sécurité
import
ldapEscape
from
'
ldap-escape
'
;
// Imports internes
import
{
ldapConfig
}
from
'
./config
'
;
import
{
Basics
}
from
'
./basics
'
;
import
{
userData
}
from
'
../export/user
'
;
...
...
@@ -82,6 +85,8 @@ export class Tools {
let
attribute
=
""
;
if
(
domain
=
"
us
"
)
{
attribute
=
ldapConfig
.
user
[
key
];
}
else
{
attribute
=
ldapConfig
.
group
[
key
];
}
// Escape user input
val
=
ldapEscape
.
dn
(
"
${fil}
"
,
{
fil
:
val
});
// Creation incrémentale du filtre
filter
=
"
(&
"
+
filter
+
"
(|(
"
+
attribute
+
"
=
"
+
val
+
"
)
"
+
// On cherche la valeur exacte
"
(|(
"
+
attribute
+
"
=*
"
+
val
+
"
)
"
+
// La valeur finale avec des trucs avant ; wildcard * (MEF la wildcart ne marche pas pour tous les attributs)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment