gopgkrb5

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 10 Imported by: 2

README

gopgkrb5

Adds the dependencies necessary for Go PG drivers to access krb5.

It is a separate repository for reducing dependencies and is heavily inherited from the lib/pq library.

Usage with jackc/pgconn and friends

Add the library:

go get github.com/otan/gopgkrb5

and initialise the package and import the package into pgconn:

import (
 "github.com/jackc/pgconn"
 "github.com/otan/gopgkrb5"
)

func init() {
  pgconn.RegisterGSSProvider(func() (pgconn.GSS, error) { return gopgkrb5.NewGSS() })
}
Unix only features

Optional settings are available:

import (
 "github.com/jcmturner/gokrb5/v8/client"
 "github.com/jackc/pgconn"
 "github.com/otan/gopgkrb5"
)

func init() {
  pgconn.RegisterGSSProvider(func() (pgconn.GSS, error) { return gopgkrb5.NewGSS(client.NewSettings(...)) })
}

You can also use keytab to log in:

func init() {
  pgconn.RegisterGSSProvider(func() (pgconn.GSS, error) {
	  return gopgkrb5.NewGSSWithKeytab("username", "DOMAIN.LOCAL", "/test.keytab")
  })
}

or password:

func init() {
  pgconn.RegisterGSSProvider(func() (pgconn.GSS, error) {
	  return gopgkrb5.NewGSSWithPassword("username", "DOMAIN.LOCAL", "password")
  })
}

All dependencies of jackc/pgconn, e.g. jackc/pgx will now be able to authenticate with GSSAPI/krb5.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GSS

type GSS struct {
	// contains filtered or unexported fields
}

GSS implements the pq.GSS interface and the pgconn.GSS interface.

func NewGSS

func NewGSS(settings ...func(*client.Settings)) (*GSS, error)

NewGSS creates a new GSS provider.

func NewGSSWithKeytab added in v1.0.2

func NewGSSWithKeytab(username string, realm string, ktPath string, settings ...func(settings *client.Settings)) (*GSS, error)

func NewGSSWithPassword added in v1.0.4

func NewGSSWithPassword(username string, realm string, password string, settings ...func(settings *client.Settings)) (*GSS, error)

func (*GSS) Continue

func (g *GSS) Continue(inToken []byte) (done bool, outToken []byte, err error)

Continue implements the GSS interface.

func (*GSS) GetInitToken

func (g *GSS) GetInitToken(host string, service string) ([]byte, error)

GetInitToken implements the GSS interface.

func (*GSS) GetInitTokenFromSPN

func (g *GSS) GetInitTokenFromSPN(spn string) ([]byte, error)

GetInitTokenFromSPN implements the GSS interface.

func (*GSS) GetInitTokenFromSpn added in v1.0.3

func (g *GSS) GetInitTokenFromSpn(spn string) ([]byte, error)

GetInitTokenFromSpn implements the GSS interface.

Jump to

Keyboard shortcuts

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