Skip to content

Commit

Permalink
Introduce basic LDAP authentication.
Browse files Browse the repository at this point in the history
  • Loading branch information
fraggerfox committed Dec 16, 2024
1 parent 4c5a7bd commit 00c4aea
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
gist.db
.idea/
.vscode/
.DS_Store
/**/.DS_Store
public/assets/*
Expand All @@ -9,3 +10,4 @@ opengist
build/
docs/.vitepress/dist/
docs/.vitepress/cache/
vendor/
131 changes: 131 additions & 0 deletions config.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Learn more about Opengist configuration here:
# https://github.com/thomiceli/opengist/blob/master/docs/configuration/configure.md
# https://github.com/thomiceli/opengist/blob/master/docs/configuration/cheat-sheet.md

# Set the log level to one of the following: debug, info, warn, error, fatal. Default: warn
log-level: info

# Set the log output to one or more of the following: `stdout`, `file`. Default: stdout,file
log-output: stdout,file

# Public URL to access to Opengist
external-url:

# Directory where Opengist will store its data. Default: ~/.opengist/
opengist-home:

# Secret key used for session store & encrypt MFA data on database. Default: <randomized 32 bytes>
secret-key:

# URI of the database. Default: opengist.db (SQLite)
# SQLite: file name
# PostgreSQL: postgres://user:password@host:port/database
# MySQL/MariaDB: mysql://user:password@host:port/database
db-uri: opengist.db

# Enable or disable the code search index (either `true` or `false`). Default: true
index.enabled: true

# Name of the directory where the code search index is stored. Default: opengist.index
index.dirname: opengist.index

# Default branch name used by Opengist when initializing Git repositories.
# If not set, uses the Git default branch name. See https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup#_new_default_branch
git.default-branch:

# Set the journal mode for SQLite. Default: WAL
# See https://www.sqlite.org/pragma.html#pragma_journal_mode
# For SQLite databases only.
sqlite.journal-mode: WAL


# HTTP server configuration
# Host to bind to. Default: 0.0.0.0
http.host: 0.0.0.0

# Port to bind to. Default: 6157
http.port: 6157

# Enable or disable git operations (clone, pull, push) via HTTP (either `true` or `false`). Default: true
http.git-enabled: true

# SSH built-in server configuration
# Note: it is not using the SSH daemon from your machine (yet)

# Enable or disable SSH built-in server
# for git operations (clone, pull, push) via SSH (either `true` or `false`). Default: true
ssh.git-enabled: true

# Host to bind to. Default: 0.0.0.0
ssh.host: 0.0.0.0

# Port to bind to. Default: 2222
# Note: it cannot be the same port as the SSH daemon if it's currently running
# If you want to use the port 22 for the built-in SSH server,
# you can either change the port of the SSH daemon or stop it
ssh.port: 2222

# Public domain for the Git SSH connection, if it has to be different from the HTTP one.
# If not set, uses the URL from the request
ssh.external-domain:

# Path or alias to ssh-keygen executable. Default: ssh-keygen
ssh.keygen-executable: ssh-keygen

# OAuth2 configuration
# The callback/redirect URL must be http://opengist.url/oauth/<github|gitlab|gitea|openid-connect>/callback

# To create a new OAuth2 application using GitHub : https://github.com/settings/applications/new
github.client-key:
github.secret:

# To create a new OAuth2 application using Gitlab : https://gitlab.com/-/user_settings/applications
gitlab.client-key:
gitlab.secret:
# URL of the Gitlab instance. Default: https://gitlab.com/
gitlab.url: https://gitlab.com/
# The name of the GitLab instance. It is displayed in the OAuth login button. Default: GitLab
gitlab.name: GitLab

# To create a new OAuth2 application using Gitea : https://gitea.domain/user/settings/applications
gitea.client-key:
gitea.secret:
# URL of the Gitea instance. Default: https://gitea.com/
gitea.url: https://gitea.com/
# The name of the Gitea instance. It is displayed in the OAuth login button. Default: Gitea
gitea.name: Gitea

# To create a new OAuth2 application using OpenID Connect:
oidc.client-key: "opengist"
oidc.secret: "WrtxMEoXCoE4M.52WQ4ea_Z0A6zISELu8zU4iN_4T3BEdLGHkc23mSqhr0R7a6-svSjgyC4l"
# Discovery endpoint of the OpenID provider. Generally something like http://auth.example.com/.well-known/openid-configuration
oidc.discovery-url: "https://auth.planet-express.in/.well-known/openid-configuration"

# LDAP authentication configuration
# URL of the LDAP instance e.g: ldap://ldap.example.com:389
ldap.url: "ldap://localhost:8888"
# Bind DN to authenticate against the LDAP e.g: cn=read-only-admin,dc=example,dc=com
ldap.bind-dn: "cn=ReadOnlyBind,ou=Applications,dc=planet-express,dc=in"
# The password for the Bind DN.
ldap.bind-credentials: "qdfpvQJ7xfUl7hzJxVgd"
# The Base DN to start search from e.g: dc=example,dc=com
ldap.search-base: "ou=people,dc=planet-express,dc=in"
# The filter to search against (the format string %s will be replaced with the username) e.g: (uid=%s)
ldap.search-filter: "(uid=%s)"

# Instance name
# Set your own custom name to be displayed instead of 'Opengist'
custom.name:

# Custom assets
# Add your own custom assets, that are files relatives to $opengist-home/custom/
custom.logo:
custom.favicon:

# Static pages in footer (like legal notices, privacy policy, etc.)
# The path can be a URL or a relative path to a file in the $opengist-home/custom/ directory
custom.static-links:
# - name: Gitea
# path: https://gitea.com
# - name: Legal notices
# path: legal.html
12 changes: 12 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ oidc.secret:
# Discovery endpoint of the OpenID provider. Generally something like http://auth.example.com/.well-known/openid-configuration
oidc.discovery-url:

# LDAP authentication configuration
# URL of the LDAP instance e.g: ldap://ldap.example.com:389
ldap.url:
# Bind DN to authenticate against the LDAP e.g: cn=read-only-admin,dc=example,dc=com
ldap.bind-dn:
# The password for the Bind DN.
ldap.bind-credentials:
# The Base DN to start search from e.g: dc=example,dc=com
ldap.search-base:
# The filter to search against (the format string %s will be replaced with the username) e.g: (uid=%s)
ldap.search-filter:

# Instance name
# Set your own custom name to be displayed instead of 'Opengist'
custom.name:
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration/admin-panel.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Here you can change a limited number of settings without restarting the instance
- Forbid the creation of new accounts.
- Require login
- Enforce users to be logged in to see gists.
- Enable LDAP
- Allow users to use LDAP authentication. If LDAP authentication fails, it will try local authentication.
- Allow individual gists without login
- Allow individual gists to be viewed and downloaded without login, while requiring login for discovering gists.
- Disable login form
Expand Down
5 changes: 5 additions & 0 deletions docs/configuration/cheat-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ aside: false
| oidc.client-key | OG_OIDC_CLIENT_KEY | none | The client key for the OpenID application. |
| oidc.secret | OG_OIDC_SECRET | none | The secret for the OpenID application. |
| oidc.discovery-url | OG_OIDC_DISCOVERY_URL | none | Discovery endpoint of the OpenID provider. |
| ldap.url | OG_LDAP_URL | `ldap://0.0.0.0:389` | URL of the LDAP instance. |
| ldap.bind-dn | OG_LDAP_BIND_DN | none | Bind DN to authenticate against the LDAP. |
| ldap.bind-credentials | OG_LDAP_BIND_CREDENTIALS | none | The password for the Bind DN. |
| ldap.search-base | OG_LDAP_SEARCH_BASE | none | The Base DN to start search from. |
| ldap.search-filter | OG_LDAP_SEARCH_FILTER | none | The filter to search against (the format string %s will be replaced with the username). |
| custom.name | OG_CUSTOM_NAME | none | The name of your instance, to be displayed in the tab title |
| custom.logo | OG_CUSTOM_LOGO | none | Path to an image, relative to $opengist-home/custom. |
| custom.favicon | OG_CUSTOM_FAVICON | none | Path to an image, relative to $opengist-home/custom. |
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/blevesearch/bleve/v2 v2.4.3
github.com/dustin/go-humanize v1.0.1
github.com/glebarez/sqlite v1.11.0
github.com/go-ldap/ldap/v3 v3.4.8
github.com/go-playground/validator/v10 v10.23.0
github.com/go-webauthn/webauthn v0.11.2
github.com/google/uuid v1.6.0
Expand All @@ -34,6 +35,7 @@ require (

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/RoaringBitmap/roaring v1.9.4 // indirect
github.com/bits-and-blooms/bitset v1.17.0 // indirect
github.com/blevesearch/bleve_index_api v1.1.13 // indirect
Expand All @@ -60,6 +62,7 @@ require (
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
Expand Down
Loading

0 comments on commit 00c4aea

Please sign in to comment.