Skip to content

Commit

Permalink
silences keystone auth log spam using a log adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
BugRoger committed Dec 22, 2017
1 parent b14b76d commit e3df9ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pkg/api/auth/keystone_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/databus23/keystone"
"github.com/databus23/keystone/cache/memory"
"github.com/go-kit/kit/log"
errors "github.com/go-openapi/errors"
flag "github.com/spf13/pflag"

Expand All @@ -19,12 +20,15 @@ func init() {
flag.StringVar(&authURL, "auth-url", "", "Openstack identity v3 auth url")
}

func Keystone() func(token string) (*models.Principal, error) {
func Keystone(logger log.Logger) func(token string) (*models.Principal, error) {

if !(strings.HasSuffix(authURL, "/v3") || strings.HasSuffix(authURL, "/v3/")) {
authURL = fmt.Sprintf("%s/%s", strings.TrimRight(authURL, "/"), "/v3")
}

keystone.Log = func(format string, a ...interface{}) {
logger.Log("library", "keystone", "msg", fmt.Sprintf(format, a...))
}
auth := keystone.New(authURL)
auth.TokenCache = memory.New(10 * time.Minute)

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/rest/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Configure(api *operations.KubernikusAPI, rt *apipkg.Runtime) error {
api.JSONProducer = runtime.JSONProducer()

// Applies when the "x-auth-token" header is set
api.KeystoneAuth = auth.Keystone()
api.KeystoneAuth = auth.Keystone(rt.Logger)

// Set your custom authorizer if needed. Default one is security.Authorized()
rules, err := auth.LoadPolicy(auth.DefaultPolicyFile)
Expand Down
9 changes: 7 additions & 2 deletions vendor/github.com/databus23/keystone/middleware.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3df9ba

Please sign in to comment.