initial commit
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Nathan Coad
2023-07-19 13:59:42 +10:00
commit 8692fa525b
7 changed files with 96 additions and 0 deletions

9
.drone.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
export now=$(TZ=Australia/Sydney date '+%Y%m%d-%H%M%S')
echo $now
echo "build commences"
go build -ldflags "-X main.sha1ver=`git rev-parse HEAD` -X main.buildTime=$now" -o authcheck
echo "build complete"
sha256sum authcheck > authcheck_checksum.txt
ls -lah

28
.drone.yml Normal file
View File

@@ -0,0 +1,28 @@
kind: pipeline
type: docker
name: default
# Docs at https://docs.drone.io/pipeline/exec/overview/
# Also see https://github.com/harness/drone-cli/blob/master/.drone.yml
steps:
- name: build
image: golang
commands:
- sh ./.drone.sh
- name: dell-deploy
# # https://github.com/cschlosser/drone-ftps/blob/master/README.md
image: cschlosser/drone-ftps
environment:
FTP_USERNAME:
from_secret: FTP_USERNAME
FTP_PASSWORD:
from_secret: FTP_PASSWORD
PLUGIN_HOSTNAME: ftp.emc.com:21
PLUGIN_SECURE: false
PLUGIN_VERIFY: false
PLUGIN_CHMOD: false
#PLUGIN_DEBUG: false
PLUGIN_INCLUDE: ^authcheck$,^authcheck_checksum.txt$
PLUGIN_EXCLUDE: ^\.git/$

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
log.txt

0
README.md Normal file
View File

11
go.mod Normal file
View File

@@ -0,0 +1,11 @@
module go-authcheck
go 1.19
require github.com/korylprince/go-ad-auth/v3 v3.3.0
require (
github.com/go-asn1-ber/asn1-ber v1.4.1 // indirect
github.com/go-ldap/ldap/v3 v3.1.7 // indirect
golang.org/x/text v0.3.2 // indirect
)

10
go.sum Normal file
View File

@@ -0,0 +1,10 @@
github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-asn1-ber/asn1-ber v1.4.1 h1:qP/QDxOtmMoJVgXHCXNzDpA0+wkgYB2x5QoLMVOciyw=
github.com/go-asn1-ber/asn1-ber v1.4.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-ldap/ldap/v3 v3.1.7 h1:aHjuWTgZsnxjMgqzx0JHwNqz4jBYZTcNarbPFkW1Oww=
github.com/go-ldap/ldap/v3 v3.1.7/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q=
github.com/korylprince/go-ad-auth/v3 v3.3.0 h1:iXuB+sCk4GniHnpUn0BAHH8rKeOLTKuYcBNvERa773Y=
github.com/korylprince/go-ad-auth/v3 v3.3.0/go.mod h1:19M0geaOeNN489k1MO6GCqOCgbruYRQkHRBfhhUZAoE=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

37
main.go Normal file
View File

@@ -0,0 +1,37 @@
package main
import (
"flag"
"fmt"
auth "github.com/korylprince/go-ad-auth/v3"
)
func main() {
// Process command line arguments
server := flag.String("server", "ldap.example.com", "LDAP server to bind to")
baseDN := flag.String("baseDN", "OU=Users,DC=example,DC=com", "Base DN to use when attempting to bind to AD")
username := flag.String("username", "user", "Username to use when attempting to bind to AD")
password := flag.String("password", "pass", "Password to use when attempting to bind to AD")
config := &auth.Config{
Server: *server,
Port: 636,
BaseDN: *baseDN,
Security: auth.SecurityStartTLS,
}
status, err := auth.Authenticate(config, *username, *password)
if err != nil {
//handle err
fmt.Println(err)
}
if !status {
//handle failed authentication
fmt.Println(err)
}
fmt.Println("success")
}