Giter Club home page Giter Club logo

gopgkrb5's Introduction

Y Y Y

Y Y Y

gopgkrb5's People

Contributors

otan avatar rafiss avatar sireax avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

gopgkrb5's Issues

can't set krbspn and krbsrvname

Hello! I am currently trying to use your library along with pgx and pgconn. The thing is - I can't set neither krbspn nor krbsrvname parameter

Code

package main

import (
	"context"
	"github.com/jackc/pgconn"
	"github.com/jackc/pgx/v4"
	"github.com/otan/gopgkrb5"
	"github.com/sirupsen/logrus"
)

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

func main() {

	conf, err := pgx.ParseConfig("postgres://[email protected]:nopassword@postgres:5432/vault?krbsrvname=postgres1&sslmode=disable")
	if err != nil {
		panic(err)
	}

	logrus.Info(conf.Config.RuntimeParams)

	conn, err := pgx.ConnectConfig(context.Background(), conf)
	defer conn.Close(context.Background())
	if err != nil {
		panic(err)
	}

	res, err := conn.Query(context.Background(), "SELECT * FROM information_schema.tables;")
	if err != nil {
		panic(err)
	}
	logrus.Println(res.Values())
	return
}

And it panics with
panic: failed to connect to host=postgres [email protected] database=vault: failed GSS auth (kerberos error (InitSecContext): [R
oot cause: KDC_Error] KDC_Error: TGS Exchange Error: kerberos error response from KDC when requesting for postgres/postgres: KRB Error: (7)
KDC_ERR_S_PRINCIPAL_UNKNOWN Server not found in Kerberos database - LOOKING_UP_SERVER)

The KDC works perfectly, because I can connect with GSSAPI using psql without any promlem. The thing is, when I try to override krbsrvname, it is not changing (as i can tell from panic message)

Packages versions I am using:

github.com/jackc/pgconn v1.12.0
github.com/jackc/pgx/v4 v4.16.0
github.com/otan/gopgkrb5 v1.0.1
github.com/sirupsen/logrus v1.8.1

Unable to use GSSAPI encryption

I really don't know if it's something wrong with gokrb5 library, or pgx, but just for sure I will duplicate issue from pgx library here: jackc/pgx#1220

I am using kerberos authentication to connect to postgres. In pg_hba.conf there is a separate host type hostgssenc, which enables secure data transport between client and server. If I use this line:

host all all 0.0.0.0/0 gss include_realm=1 krb_realm=DOMAIN1.LOCAL

everything works fine. However, the connection is not secure.
If I change host to hostgssenc, I get this error:

failed to connect to host=postgres user=[email protected] database=vault: server error (FATAL: no pg_hba.conf entry for host "172.18.0.2", user "[email protected]", database "vault", no encryption (SQLSTATE 28000))

If I connect to postgres via psql, the connection becomes secure along with authentication.

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.