Coder Social home page Coder Social logo

gosasl's Introduction

go Kerberos sasl authtication steps

1. go

go 1.19

2. basic software

2.1 hbase 1.2.6.1

https://archive.apache.org/dist/hbase/1.2.6.1/

2.2 thrift 0.9.3

http://archive.apache.org/dist/thrift/0.9.3/

2.3 libkrb5

Ubuntu: sudo apt-get install libkrb5-dev
MacOS: brew install homebrew/dupes/heimdal --without-x11
Debian: yum install -y krb5-devel 

3. go dependence

3.1 go thrift

go get git.apache.org/thrift.git/lib/go/[email protected]

3.2 go gosasl

go get -tags kerberos github.com/beltran/gosasl

3.3 thrift hbase client(already integration,pass to 4)

tar -zxvf hbase-1.2.6.1-src-tar.gz && cd hbase-1.2.6.1
thrift --out ./ --gen go ./hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
cp -r ./hbase/* {you application dir}

4.export env

export KRB5CCNAME={your file path}
export KRB5_CONFIG={your file path}

5. install & run & build

go get github.com/spierman/gosasl
go run -tags kerberos {XX}.go
go build -tags kerberos {XX}.go

6. example code

```
import (
    "fmt"
    "log"
    "os"
    sasl "github.com/spierman/gosasl"
"github.com/spierman/gosasl/hbase"
)

func main() {
    host := "XX.com"
    port := 9090
    table := "aa"
    connection, err := sasl.Connect(host, port, sasl.WithGSSAPISaslTransport("hbase"))
    if err != nil {
        log.Fatal("Error connecting", err)
        return
    }
    l := log.New(os.Stderr, "GOKRB5 Client: ", log.LstdFlags)
    client := hbase.NewHbaseClientFactory(connection.Transport, connection.ProtocolFactory)
    isExists, err := client.IsTableEnabled([]byte(table))
    if err != nil {
        l.Fatalf("could not load: %v", err)
    }
    fmt.Printf("rst {%s}\n", isExists)
}
```

7. issuse

if the hbase.go report error,please replace like this
```
replace temp  to  string(temp[:])

```

gosasl's People

Contributors

spierman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.