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
72395351
Commit
72395351
authored
5 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Upgrade id/auth (tracing)
parent
a1bb2db9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vendor/git.autistici.org/id/auth/client/client.go
+35
-2
35 additions, 2 deletions
vendor/git.autistici.org/id/auth/client/client.go
vendor/vendor.json
+3
-3
3 additions, 3 deletions
vendor/vendor.json
with
38 additions
and
5 deletions
vendor/git.autistici.org/id/auth/client/client.go
+
35
−
2
View file @
72395351
...
...
@@ -6,6 +6,7 @@ import (
"net/textproto"
"github.com/cenkalti/backoff"
"go.opencensus.io/trace"
"git.autistici.org/id/auth"
)
...
...
@@ -29,19 +30,31 @@ func New(socketPath string) Client {
}
func
(
c
*
socketClient
)
Authenticate
(
ctx
context
.
Context
,
req
*
auth
.
Request
)
(
*
auth
.
Response
,
error
)
{
// Create a tracing span for the authentication request.
sctx
,
span
:=
trace
.
StartSpan
(
ctx
,
"auth-server.Authenticate"
,
trace
.
WithSpanKind
(
trace
.
SpanKindClient
))
defer
span
.
End
()
span
.
AddAttributes
(
trace
.
StringAttribute
(
"auth.service"
,
req
.
Service
),
trace
.
StringAttribute
(
"auth.username"
,
req
.
Username
),
)
// Retry the request, with backoff, if we get a temporary
// network error.
var
resp
*
auth
.
Response
err
:=
backoff
.
Retry
(
func
()
error
{
var
err
error
resp
,
err
=
c
.
doAuthenticate
(
ctx
,
req
)
resp
,
err
=
c
.
doAuthenticate
(
s
ctx
,
req
)
if
err
==
nil
{
return
nil
}
else
if
netErr
,
ok
:=
err
.
(
net
.
Error
);
ok
&&
netErr
.
Temporary
()
{
return
netErr
}
return
backoff
.
Permanent
(
err
)
},
backoff
.
WithContext
(
backoff
.
NewExponentialBackOff
(),
ctx
))
},
backoff
.
WithContext
(
backoff
.
NewExponentialBackOff
(),
sctx
))
span
.
SetStatus
(
responseToTraceStatus
(
resp
,
err
))
return
resp
,
err
}
...
...
@@ -93,3 +106,23 @@ func (c *socketClient) doAuthenticate(ctx context.Context, req *auth.Request) (*
return
nil
,
ctx
.
Err
()
}
}
func
responseToTraceStatus
(
resp
*
auth
.
Response
,
err
error
)
trace
.
Status
{
switch
err
{
case
nil
:
switch
resp
.
Status
{
case
auth
.
StatusOK
:
return
trace
.
Status
{
Code
:
trace
.
StatusCodeOK
,
Message
:
"OK"
}
case
auth
.
StatusInsufficientCredentials
:
return
trace
.
Status
{
Code
:
trace
.
StatusCodePermissionDenied
,
Message
:
"Insufficient Credentials"
}
default
:
return
trace
.
Status
{
Code
:
trace
.
StatusCodePermissionDenied
,
Message
:
"Authentication Failure"
}
}
case
context
.
Canceled
:
return
trace
.
Status
{
Code
:
trace
.
StatusCodeCancelled
,
Message
:
"CANCELED"
}
case
context
.
DeadlineExceeded
:
return
trace
.
Status
{
Code
:
trace
.
StatusCodeDeadlineExceeded
,
Message
:
"DEADLINE_EXCEEDED"
}
default
:
return
trace
.
Status
{
Code
:
trace
.
StatusCodeUnknown
,
Message
:
err
.
Error
()}
}
}
This diff is collapsed.
Click to expand it.
vendor/vendor.json
+
3
−
3
View file @
72395351
...
...
@@ -33,10 +33,10 @@
"revisionTime"
:
"2019-10-24T15:02:31Z"
},
{
"checksumSHA1"
:
"
3xM1BQ7kVyqn74GQz07uCBSNh2E
="
,
"checksumSHA1"
:
"
bcwQ+zvfpEIZtOKPVXeaG1XyhfI
="
,
"path"
:
"git.autistici.org/id/auth/client"
,
"revision"
:
"
ffc5d8791fd81d28fb2b0bce4540a10426a25124
"
,
"revisionTime"
:
"20
19-10-24T15:02:31
Z"
"revision"
:
"
3d44524ae2e5a232f4620329a68fb00d3048953a
"
,
"revisionTime"
:
"20
20-02-12T08:17:28
Z"
},
{
"checksumSHA1"
:
"MlpsZgRytv/c9IX9YawRJDN/ibQ="
,
...
...
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