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
88786ca6
Commit
88786ca6
authored
7 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Log requests
parent
b7c86593
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dovecot/keyproxy.go
+7
-0
7 additions, 0 deletions
dovecot/keyproxy.go
with
7 additions
and
0 deletions
dovecot/keyproxy.go
+
7
−
0
View file @
88786ca6
...
...
@@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"errors"
"log"
"strings"
"git.autistici.org/ai3/go-common/clientutil"
...
...
@@ -96,8 +97,10 @@ func (s *KeyLookupProxy) Lookup(ctx context.Context, key string) (interface{}, b
func
(
s
*
KeyLookupProxy
)
lookupUserdb
(
ctx
context
.
Context
,
username
string
)
(
interface
{},
bool
)
{
pub
:=
s
.
db
.
GetPublicKey
(
ctx
,
username
)
if
pub
==
nil
{
log
.
Printf
(
"failed userdb lookup for %s"
,
username
)
return
nil
,
false
}
log
.
Printf
(
"userdb lookup for %s"
,
username
)
return
&
userdbResponse
{
PublicKey
:
b64encode
(
pub
)},
true
}
...
...
@@ -106,6 +109,7 @@ func (s *KeyLookupProxy) lookupPassdb(ctx context.Context, username, password st
// unencrypted key from the keystore daemon.
priv
,
err
:=
s
.
keystore
.
Get
(
ctx
,
s
.
config
.
Shard
,
username
,
password
)
if
err
==
nil
{
log
.
Printf
(
"passdb lookup for %s (from keystore)"
,
username
)
return
&
passdbResponse
{
PrivateKey
:
b64encode
(
priv
)},
true
}
...
...
@@ -113,12 +117,15 @@ func (s *KeyLookupProxy) lookupPassdb(ctx context.Context, username, password st
// decrypt them.
encKeys
:=
s
.
db
.
GetPrivateKeys
(
ctx
,
username
)
if
len
(
encKeys
)
==
0
{
log
.
Printf
(
"failed passdb lookup for %s (no keys)"
,
username
)
return
nil
,
false
}
priv
,
err
=
userenckey
.
Decrypt
(
encKeys
,
[]
byte
(
password
))
if
err
!=
nil
{
log
.
Printf
(
"failed passdb lookup for %s (could not decrypt key)"
,
username
)
return
nil
,
false
}
log
.
Printf
(
"passdb lookup for %s (decrypted)"
,
username
)
return
&
passdbResponse
{
PrivateKey
:
b64encode
(
priv
)},
true
}
...
...
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