No description
- Go 100%
|
|
||
|---|---|---|
| .vscode | ||
| config | ||
| lib | ||
| log | ||
| middleware | ||
| rest | ||
| route | ||
| structs | ||
| .dockerignore | ||
| .drone.yml | ||
| .gitignore | ||
| Dockerfile.386 | ||
| Dockerfile.amd64 | ||
| Dockerfile.arm | ||
| Dockerfile.arm64 | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| README.md | ||
| TODO | ||
Проверка аутентификации пользователя через REST
Простейшее приложение для проверки логина и пароля в LDAP для приложений без поддержки LDAP.
Аутентификация
POST:
{
"login":"test",
"password":"test"
}
Response:
{ "result":true }
Поиск в каталоге
GET:
GET http://localhost:3000?login=&surname=&name=&farname=&email
Response:
[
{
"login": "",
"surname": "",
"name": "",
"farname": "",
"email": ""
}
]
Для того, чтобы поля в LDAP были сопоставлены с полями структуры вывода информации, необходимо настроить параметры ldap.fields (см. ниже)
Параметры
Необходимо задать переменные окружения или параметры. Так же параметры могут быть загружены из JSON-файла config/config.json.
{
Env string arg:"-e,--environment,env:ENV" default:"prod" help:"Environment for application. dev or prod" json:"env,omitempty"
Web struct {
Port int `arg:"-p,--port,env:WEB_PORT" default:"3000" help:"Open port for incoming connections" json:"port,omitempty"`
Token string `arg:"--token,env:WEB_TOKEN" default:"" help:"Token for auth" json:"token,omitempty"`
TLS bool `arg:"-t,--tls,env:WEB_TLS" default:"false" help:"Use TLS" json:"tls,omitempty"`
HTTPVersion int `arg:"--web-http-version,env:WEB_HTTP_VERSION" default:"2" help:"HTTP version protocol/ May be set 2 or 3. Default 2" json:"httpVersion,omitempty"`
TLSPort int `arg:"--tls-port,env:WEB_TLS_PORT" default:"3443" help:"Open port for incoming TLS connections" json:"tlsPort,omitempty"`
TLSMinVersion string `arg:"--web-tls-min-version,env:WEB_TLS_MIN_VERSION" default:"1.0" help:"Minimum TLS version" json:"tlsMinVersion,omitempty"`
TLSMaxVersion string `arg:"--web-tls-max-version,env:WEB_TLS_MAX_VERSION" default:"1.3" help:"Maximum TLS version" json:"tlsMaxVersion,omitempty"`
TLSCert string `arg:"--web-tls-cert,env:WEB_TLS_CERT" default:"" help:"Path to certificate for TLS" json:"tlsCert,omitempty"`
TLSKey string `arg:"--web-tls-key,env:WEB_TLS_KEY" default:"" help:"Path to key for TLS certificate" json:"tlsKey,omitempty"`
} `arg:"-" json:"web,omitempty"`
Ldap struct {
Url string `arg:"--ldap-url,env:LDAP_URL" default:"" help:"Ldap address for connect with format ldap[s]://<address>:<port>. May get ldaps protocol" json:"url,omitempty"`
BindDN string `arg:"--ldap-binddn,env:LDAP_BINDDN" default:"" help:"BindDN for auth" json:"bindDN,omitempty"`
BindCredentials string `arg:"--ldap-credential,env:LDAP_CREDENTIAL" default:"" help:"Password for connect to Ldap" json:"bindCredentials,omitempty"`
SearchBase string `arg:"--ldap-search-base,env:LDAP_SEARCH_BASE" default:"" help:"Root path for start search object" json:"searchBase,omitempty"`
SearchFilter string `arg:"--ldap-search-filter,env:LDAP_SEARCH_FILTER" default:"" help:"String in ldap format for filtering records" json:"searchFilter,omitempty"`
SearchScope string `arg:"--ldap-search-scope,env:LDAP_SEARCH_SCOPE" default:"" help:"String for get get columns" json:"searchScope,omitempty"`
Reconnect bool `arg:"--ldap-reconnect,env:LDAP_RECONNECT" default:"true" help:"Reconnect to LDAP" json:"reconnect,omitempty"` // Перезапускать соединение после ошибки
TlsOptions struct {
RejectUnauthorized bool `arg:"--ldap-reject-unauthorized-tls,env:LDAP_REJECT_UNAUTHORIZED_TLS" help:"Disable verify tls cert" json:"rejectUnauthorized,omitempty"` // Отключить проверку подлинности
} `arg:"-" json:"tlsOptions,omitempty"`
AllowSearch bool `arg:"--ldap-allow-search,env:LDAP_ALLOW_SEARCH" default:"false" help:"Разрешает производить поиск пользователей в каталоге LDAP" json:"allowSearch,omitempty"`
Fields struct {
Login string `arg:"--login,env:LDAP_FIELDS_LOGIN" default:"sAMAccountName" help:"Поле логина из LDAP" json:"login,omitempty"`
Surname string `arg:"--surname,env:LDAP_FIELDS_SURNAME" default:"sn" help:"Имя поля фамилии из LDAP" json:"surname,omitempty"`
Name string `arg:"--name,env:LDAP_FIELDS_NAME" default:"givenName" help:"Имя поля имени из LDAP" json:"name,omitempty"`
Farname string `arg:"--farname,env:LDAP_FIELDS_FARNAME" default:"middleName" help:"Имя поля отчества из LDAP" json:"farname,omitempty"`
Email string `arg:"--email,env:LDAP_FIELDS_EMAIL" default:"mail" help:"Email поля из LDAP" json:"email,omitempty"`
} `arg:"-" json:"fields,omitempty"`
} `arg:"-" json:"ldap"`
Log struct {
Endpoint string `arg:"--log-endpoint,env:LOG_ENDPOINT" default:"" help:"Endpoint for send logs ion remote server" json:"logEndpoint,omitempty"`
} `arg:"-" json:"logging,omitempty"`
}
Проверка подлинности проверяется из параметра загаловка в запросе Authorization: Token <токен авторизации>.