Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
keystore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
id
keystore
Commits
e0d673fd
Commit
e0d673fd
authored
2 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Fix dovecot-keylookupd logging to log a single line per request
parent
becc7e22
No related branches found
No related tags found
1 merge request
!33
Fix dovecot-keylookupd logging to log a single line per request
Pipeline
#45230
passed
2 years ago
Stage: build
Stage: release
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dovecot/keyproxy.go
+10
-5
10 additions, 5 deletions
dovecot/keyproxy.go
with
10 additions
and
5 deletions
dovecot/keyproxy.go
+
10
−
5
View file @
e0d673fd
...
...
@@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"errors"
"fmt"
"log"
"strings"
...
...
@@ -153,15 +154,17 @@ func (s *KeyLookupProxy) lookupUserdb(ctx context.Context, username string) (int
func
(
s
*
KeyLookupProxy
)
lookupPassdb
(
ctx
context
.
Context
,
username
,
password
string
)
(
interface
{},
bool
,
error
)
{
// The password might be a SSO token, so first of all we try
// to fetch the unencrypted key from the keystore daemon.
var
keystoreStatus
string
priv
,
err
:=
s
.
keystore
.
Get
(
ctx
,
s
.
config
.
Shard
,
username
,
password
)
switch
{
case
err
==
client
.
ErrNoKeys
:
log
.
Printf
(
"no encryption keys for %s in keystore"
,
username
)
keystoreStatus
=
"no keys available"
case
isErr403
(
err
)
:
log
.
Printf
(
"no encryption keys for %s in keystore (no SSO token)"
,
username
)
keystoreStatus
=
"no SSO token"
case
err
!=
nil
:
// This is an unexpected error.
log
.
Printf
(
"keystore lookup for %s failed: %v"
,
username
,
err
)
keystoreStatus
=
fmt
.
Sprintf
(
"unexpected error: %v"
,
err
)
default
:
log
.
Printf
(
"passdb lookup for %s (from keystore)"
,
username
)
return
newPassDBResponse
(
s
.
b64encode
(
priv
)),
true
,
nil
...
...
@@ -174,20 +177,22 @@ func (s *KeyLookupProxy) lookupPassdb(ctx context.Context, username, password st
return
nil
,
false
,
err
}
if
len
(
encKeys
)
==
0
{
// If there are no keys in the db, the keystore status
// is not really relevant.
log
.
Printf
(
"no encryption keys for %s in database"
,
username
)
return
nil
,
false
,
nil
}
key
,
err
:=
userenckey
.
Decrypt
(
encKeys
,
[]
byte
(
password
))
if
err
!=
nil
{
log
.
Printf
(
"failed passdb lookup for %s (could not decrypt key)
"
,
username
)
log
.
Printf
(
"failed passdb lookup for %s (could not decrypt key)
, keystore status: %s"
,
username
,
keystoreStatus
)
return
nil
,
false
,
err
}
priv
,
err
=
key
.
PEM
()
if
err
!=
nil
{
log
.
Printf
(
"failed passdb lookup for %s (obtained invalid key: %v)
"
,
username
,
err
)
log
.
Printf
(
"failed passdb lookup for %s (obtained invalid key: %v)
, keystore status: %s"
,
username
,
err
,
keystoreStatus
)
return
nil
,
false
,
err
}
log
.
Printf
(
"passdb lookup for %s (
decrypted
)"
,
username
)
log
.
Printf
(
"passdb lookup for %s (
from database
)"
,
username
)
return
newPassDBResponse
(
s
.
b64encode
(
priv
)),
true
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment