A small Go library for creating JWTs based on LDAP user credentials including group checks.
To install go-ldap-jwt, use go get
:
go get github.com/haro87/go-ldap-jwt
This will make the following packages available to you:
github.com/haro87/go-ldap-jwt/config
- Import the
github.com/haro87/go-ldap-jwt/config
and use it to retrieve the configuration:
package yours
import (
"github.com/haro87/go-ldap-jwt/config"
)
func LoadConfig() {
// In case you use secrets in a Docker container you can
// provide the default secrets location via the `secrets`
// parameter. If nothing is provided then the default:
// `/run/secrets/` is used.
config, err := config.GetConfig("path/to/config.yaml", "")
}
# ./configs/config.yaml
# Servers config
servers:
- protocol: ldaps # defaults to ldaps if not provided
host: some-ldap-server.com
port: 636 # defaults to 636 if not provided
# Bind user config
# can also work with reading secrets from file
user:
name: testuser
password: test1234
# Groups config
groups:
objectclass: user # defaults to user if not provided
memberattribute: memberOf # defaults to memberOf if not provided
definitions:
- some-group
- some-other-group
# JWT config
jwt:
expire: 30m
signingkey: somekey
MIT © HaRo87.