Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
go-sso
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
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
go-sso
Commits
a7b1ae99
Commit
a7b1ae99
authored
5 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Log the shard when we are unlocking a key
parent
8d3f4507
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/http.go
+11
-7
11 additions, 7 deletions
server/http.go
with
11 additions
and
7 deletions
server/http.go
+
11
−
7
View file @
a7b1ae99
...
...
@@ -188,17 +188,17 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi
// We unlock the keystore if the following conditions are met:
// keystore_enable_groups is set, userinfo is not nil, and the groups match.
func
(
h
*
Server
)
maybeUnlockKeystore
(
ctx
context
.
Context
,
username
,
password
string
,
userinfo
*
auth
.
UserInfo
)
(
bool
,
error
)
{
func
(
h
*
Server
)
maybeUnlockKeystore
(
ctx
context
.
Context
,
username
,
password
string
,
userinfo
*
auth
.
UserInfo
)
(
bool
,
string
,
error
)
{
if
h
.
keystore
==
nil
{
return
false
,
nil
return
false
,
""
,
nil
}
if
len
(
h
.
keystoreGroups
)
>
0
{
if
userinfo
==
nil
{
return
false
,
nil
return
false
,
""
,
nil
}
if
!
inAnyGroups
(
userinfo
.
Groups
,
h
.
keystoreGroups
)
{
return
false
,
nil
return
false
,
""
,
nil
}
}
...
...
@@ -209,7 +209,7 @@ func (h *Server) maybeUnlockKeystore(ctx context.Context, username, password str
// Add a 'grace time' of 30 minutes to the key ttl.
ttl
:=
h
.
authSessionLifetime
+
1800
return
true
,
h
.
keystore
.
Open
(
ctx
,
shard
,
username
,
password
,
ttl
)
return
true
,
shard
,
h
.
keystore
.
Open
(
ctx
,
shard
,
username
,
password
,
ttl
)
}
// Callback called by the login handler whenever a user successfully
...
...
@@ -217,14 +217,18 @@ func (h *Server) maybeUnlockKeystore(ctx context.Context, username, password str
func
(
h
*
Server
)
loginCallback
(
ctx
context
.
Context
,
username
,
password
string
,
userinfo
*
auth
.
UserInfo
)
error
{
// Open the keystore for this user, with the same password
// used to authenticate.
decrypted
,
err
:=
h
.
maybeUnlockKeystore
(
ctx
,
username
,
password
,
userinfo
)
decrypted
,
shard
,
err
:=
h
.
maybeUnlockKeystore
(
ctx
,
username
,
password
,
userinfo
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to unlock keystore for user %s: %v"
,
username
,
err
)
}
var
kmsg
string
if
decrypted
{
kmsg
=
" (key unlocked)"
kmsg
=
" (key unlocked"
if
shard
!=
""
{
kmsg
+=
fmt
.
Sprintf
(
", shard %s"
,
shard
)
}
kmsg
+=
")"
}
log
.
Printf
(
"successful login for user %s%s"
,
username
,
kmsg
)
return
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