basic-oidc-go

command module
v0.0.0-...-b323f02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 14 Imported by: 0

README

Basic OIDC example in Go

Usage

Fill a .env with the OIDC issuer URL, client secret and client ID:

CLIENT_SECRET=GOCSPX-0123456789abcdefghijklmnopqr
CLIENT_ID=123456789012-0123456789abcdefghijklmnopqrstuv.apps.googleusercontent.com
OIDC_ISSUER=https://accounts.google.com

Launch the server:

go run main.go

Go to the login page: http://localhost:3000/login.

With Dex

Configure the dex by editing the dex/config.yaml. Remove or add providers.

Run the dex server by running the dex/run.sh script.

Launch the server:

go run main.go

Go to the login page: http://localhost:3000/login.

With 389ds and dex

Run the 389ds server by running the run.sh script.

Initialize the server:

docker exec -it 389ds bash

dsconf localhost backend create --suffix dc=example,dc=com --be-name example_backend # Create a backend (a backend is literally a database)
dsidm localhost initialise # Creates examples
# Create a user
dsidm -b "dc=example,dc=com" localhost user create \
  --uid example-user \
  --cn example-user \
  --displayName example-user \
  --homeDirectory "/dev/shm" \
  --uidNumber -1 \
  --gidNumber -1
# Set a user password:
dsidm -b "dc=example,dc=com" localhost user modify \
  example-user add:userPassword:"...."
dsidm -b "dc=example,dc=com" localhost user modify \
  example-user add:mail:example-user@example.com

Edit the dex configuration to include LDAP:

#config.yaml
#...
connectors:
  - type: ldap
    id: ldap
    name: LDAP
    config:
      host: <your-host-IP>:3389 # EDIT THIS. If you use docker-compose with root, you can set a domain name.
      insecureNoSSL: true
      userSearch:
        baseDN: ou=people,dc=example,dc=com
        username: uid
        idAttr: uid
        emailAttr: mail
        nameAttr: cn
        preferredUsernameAttr: uid
      groupSearch:
        baseDN: ou=groups,dc=example,dc=com
        userMatchers:
          - userAttr: uid
            groupAttr: member
        nameAttr: cn

Run the dex server by running the dex/run.sh script.

Launch the server:

go run main.go

Go to the login page: http://localhost:3000/login.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL