This commit is contained in:
9
.drone.sh
Normal file
9
.drone.sh
Normal 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
28
.drone.yml
Normal 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
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log.txt
|
11
go.mod
Normal file
11
go.mod
Normal 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
10
go.sum
Normal 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
37
main.go
Normal 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")
|
||||
}
|
Reference in New Issue
Block a user