Giter Club home page Giter Club logo

idm's Introduction

LibreGraph Identity Management

The LibreGraph Identity Management provides a LDAP server, which is easy to configure, does not have external dependencies and is tailored to work perfectly with other LibreGraph software.

The goal is that everyone who does not already have or needs an LDAP server, uses IDM.

Thus, IDM is a (currently read-only) drop in replacement for an existing LDAP server and does provide an LDAP interface if none is there already. IDM uses hard coded indexes and supports LDAP search, bind and unbind operations.

Running idmd from a source build

Until packages and containers for more environments are available it is the easiest to just create a local build of idmd. For this just run make.

IDM uses a mixture of environment variables and parameters for configuration and needs to be at least passed a the location of an individual ldif file or a directory containing multiple ldif files.

$ ./idmd serve --ldif-main ./export.ldif
INFO[0000] LDAP listener started                         listen_addr="127.0.0.1:10389"
INFO[0000] ready

Configuration

The default base DN of IDM is dc=lg,dc=local. There is usually no need to change, it if you don't use the LDAP data for anything else. The value needs to match what the clients have configured. Similarly, the default mail domain is lg.local.

Both values can be changed by passing --ldap-base-dn or --ldif-template-default-mail-domain respectively.

IDM uses ldif files for its data source and those files, the location of these files needs to be passed at startup using the --ldif-main parameter.

Adding a service user for LDAP access

By default IDM does not have any users and anonymous bind is disabled. You can enable anonymous bind support for local requests by passing --ldap-allow-local-anonymous when running idmd. Alternatively a service user can be specified in the following way:

cat <<EOF > ./config.ldif
dn: cn=readonly,{{.BaseDN}}
cn: readonly
description: LDAP read only service user
objectClass: simpleSecurityObject
objectClass: organizationalRole
userPassword: readonly
EOF

And then passed as an additional parameter when starting idmd by passing --ldif-config ./config.ldif. The config.ldif is for service users only and the data in there is used for bind requests only, but never returned for search requests.

Add users to the ldap service

idmd serves all ldif files from the folder specified by --ldif-main (loaded in lexical order and parsed as templates). Whenever any of the ldif files are changed, added or removed, make sure to restart idmd.

idmd listens on 127.0.0.1:10389 by default and does not ship with any default users. Example configuration can be found in the scripts directory of this repository.

Add new users using the gen newusers command

IDM provides a way to create ldif data for new users using batch mode similar to the unix newusers command using the following standard password file format:

uid:userPassword:uidNumber:gidNumber:cn,[mail][,mailAlternateAddress...]:ignored:ignored

For example, like this:

cat << EOF | ./idmd gen newusers - --min-password-strength=4 > ./ldif/50-users.ldif
jonas:passwordOfJonas123:::Jonas Brekke,[email protected]::
timmothy:passwordOfTimmothy456:::Timmothy Schöwalter::
EOF

This outputs an LDIF template file which you can modify as needed. When done run restart idmd to make the new users available. Keep in mind that some of the attributes must be unique.

Replace existing OpenLDAP with IDM

On the LDAP server export all its data using slapcat and write the resulting ldif to for example ./ldif/10-main.ldif. This is a drop in replacement and all what was in OpenLDAP is now also in IDM.

Either stop slapd and change the IDM configuration to listen where slapd used to listen or change the clients to connect to where idmd listens to migrate.

Extra goodies

Template support

All ldif files loaded by IDM support template syntax as defined in https://golang.org/pkg/text/template to allow auto generation and replacement of various values. You can find example templates in the scripts directory as well. All the gen commands output template syntax if applicable.

Generate secure password hash using the gen passwd command

IDM supports secure password hashing using ARGON2. To create such password hashes either use gen newusers or the interactive gen passwd which is very similar to slappasswd from OpenLDAP.

./idmd gen passwd
New password:
Re-enter new password:
{ARGON2}$argon2id$v=19$m=65536,t=1,p=2$MaB5gX2BI484dATbGFyEIg$h2X8rbPowzZ/Exsz4W20Z/Zk54C30YnY+YbivSIRpcI

Test IDM

Since idmd provides a standard LDAP interface, also standard LDAP tools can be used to interact with it for testing. Run apt install ldap-utils to install LDAP commandline tools.

ldapsearch -x -H ldap://127.0.0.1:10389 -b "dc=lg,dc=local" -D "cn=readonly,dc=lg,dc=local" -w 'readonly'

idm's People

Contributors

2403905 avatar dependabot[bot] avatar fbartels avatar longsleep avatar rhafer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

idm's Issues

Add Basic Schema support

When writing entries idm should provide at least some basic schema checks:

  • make sure objectClass Attribute is present
  • make sure the RDN attribute is present on the AttributeList, if not, add it
  • normalize AttributeTypes and objectClass Values

ideally we'd also add some syntax validation for the basic LDAP Syntaxes and validation for required and optional Attributes for the specified objectClasses.

Add indexing to boltdb

The boltDB backend should support basic search indexes for at least presence, equality and prefix matches.

Operational Attributes

We shoudl add support for some core operational Attributes. Namely:

from RFC4512:

  • creatorsName: the Distinguished Name of the user who added this entry to the directory,
  • createTimestamp: the time this entry was added to the directory,
  • modifiersName: the Distinguished Name of the user who last modified this entry, and
  • modifyTimestamp: the time this entry was last modified.

from rfc4530:

  • entryUUID

Graph API access

I am opening this issue to document some ideas we have at ownCloud.

We would like to be able to communicate with the idm using the Graph API. The API should provide read and write access, so that we can do basic CRUD actions.
This means that the idm needs some sort of storage which could be implemented using https://github.com/tidwall/buntdb for example.

cc: @micbar, @butonic

Bind from LDIF data source panics when there is no userPassword and the panic is not logged

The panic recover in

if r := recover(); r != nil {
does not get logged.

For example when for whatever reason a user record has no userPassword field, the nesting code in server/handler/ldif/entry.go goes like

ldappassword.Validate(bindSimplePw, entry.UserPassword.Values[0])

and that panics.

Panics should be logged so it is clear why Bind commands return an Operational Error and this particular case should not panic in the first place.

Can't build on alpine linux

The used go-crypt module contains glibc specific code. Alpine linux is using musl instead of glibc.

owncloud/idm # make
running gofmt ...
retrieving dependencies ...
# github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e
...
building cmd/idmd ...
CGO_ENABLED=1 go build \
        -mod=vendor \
        -trimpath \
        -tags release \
        -buildmode=exe \
        -ldflags '-s -w -buildid=reproducible/0.3.0-41-gb89b052 -X github.com/libregraph/idm/version.Version=0.3.0-41-gb89b052 -X github.com/libregraph/idm/version.BuildDate=2022-02-17T17:28:53Z -extldflags -static' \
        -o bin/idmd ./cmd/idmd
# github.com/amoghe/go-crypt
vendor/github.com/amoghe/go-crypt/version.go:6:10: fatal error: gnu/libc-version.h: No such file or directory
    6 | #include <gnu/libc-version.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:47: cmd/idmd] Error 2

idm overwrites standard logger

To be able to properly log messages of the ldap module idm is "redirecting" the standard logger to logrus:

https://github.com/libregraph/idm/blob/master/server/server.go#L131

We are currently trying to embed the idm service into ocis and this is creating a bit of on issue with any other go module that might be using the standard logger. (All messages will get the scope=ldap thing added, even if they come from completely unrelated code).

Maybe we should make that log redirection optional somehow.

Basic user management web ui

I am opening this issue to document some ideas we have at ownCloud.

We would like to have a basic web UI to manage users. The web UI could talk to the idm using the graph API #9
These operations could be:

  • list users
  • add users
  • delete users
  • lock users

This web UI doesn't necessarily need to be included in this repository, I just wanted to document this somewhere.

A first idea was to port the UI from our accounts service. https://github.com/owncloud/ocis/tree/master/accounts/ui

This also opens some implicit requirements like we would like to send invitation mails when adding users.

cc: @micbar @butonic

Wrong handling for server side sizelimit

While the server does not return more results than request. It does return the proper SIZE_LIMIT_EXCEEDED error in that case.

ldapsearch -x -H ldaps://:9235 -D uid=libregraph,ou=sysusers,o=libregraph-idm -W -b o=libregraph-idm -z1
Enter LDAP Password: 
# extended LDIF
#
# LDAPv3
# base <o=libregraph-idm> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# libregraph-idm
dn: o=libregraph-idm
o: libregraph-idm
objectClass: organization

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

Errors when processing filters that require escaping

idm currently chokes on some filters that contain escaped characters in the filter assertions. E.g.:

ldapsearch -x -H ldaps://:9235 -b o=libregraph-idm "(member=uid=a\5c+b,ou=users,o=libregraph-idm)"
[..]
# search result
search: 2
result: 1 Operations error

# numResponses: 1

where (member=uid=a\5c+b,ou=users,o=libregraph-idm) is a correctly escaped filter.

The reason seems to be that DecompileFilter (https://github.com/libregraph/idm/blob/master/pkg/ldapserver/filter.go#L63), imported from
github.com/nmcclain/ldap at some point. Does not correctly re-escape filter assertions when regenerating the string representation of the filter from BER.

Support for LDAPS

IDM should offer basic SSL support by adding an ldaps;// listener. (Support for the StartTLS operation would be nice, but I guess we could do without that.)

Restrict write access to a single DN for now

With the current implementation anybody who can successfully do a non-anonymous bind gains full write access to the entire LDAP tree. We should rework that to allow write access only for a single user, specified via CLI flag.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.