Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mizu
Commits
dac1b4fd
Commit
dac1b4fd
authored
3 years ago
by
Roy Island
Browse files
Options
Download
Email Patches
Plain Diff
fixed duplicate msg, added logs
parent
46f08521
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cli/auth/authProvider.go
+16
-10
cli/auth/authProvider.go
cli/cmd/config.go
+1
-1
cli/cmd/config.go
with
17 additions
and
11 deletions
+17
-11
cli/auth/authProvider.go
+
16
-
10
View file @
dac1b4fd
...
...
@@ -69,44 +69,50 @@ func startLoginServer(tokenChannel chan *oauth2.Token, errorChannel chan error,
serveErr
:=
server
.
Serve
(
listener
)
if
serveErr
==
http
.
ErrServerClosed
{
logger
.
Log
.
Debugf
(
"Received server shutdown, server on port %v is closed"
,
port
)
logger
.
Log
.
Debugf
(
"received server shutdown, server on port %v is closed"
,
port
)
return
}
else
if
serveErr
!=
nil
{
logger
.
Log
.
Debugf
(
"failed to start serving on port %v, err: %v"
,
port
,
serveErr
)
continue
}
logger
.
Log
.
Debugf
(
"didn't receive server closed on port %v"
,
port
)
return
}
errorChannel
<-
fmt
.
Errorf
(
"failed to start serving on all listen ports
"
)
errorChannel
<-
fmt
.
Errorf
(
"failed to start serving on all listen ports
, ports: %v"
,
listenPorts
)
}
func
loginCallbackHandler
(
tokenChannel
chan
*
oauth2
.
Token
,
errorChannel
chan
error
,
config
*
oauth2
.
Config
,
envName
string
,
state
uuid
.
UUID
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
writer
http
.
ResponseWriter
,
request
*
http
.
Request
)
{
if
err
:=
request
.
ParseForm
();
err
!=
nil
{
errorChannel
<-
fmt
.
Errorf
(
"failed to parse form, err: %v"
,
err
)
http
.
Error
(
writer
,
fmt
.
Sprintf
(
"failed to parse form, err: %v"
,
err
),
http
.
StatusBadRequest
)
errorMsg
:=
fmt
.
Sprintf
(
"failed to parse form, err: %v"
,
err
)
errorChannel
<-
fmt
.
Errorf
(
errorMsg
)
http
.
Error
(
writer
,
errorMsg
,
http
.
StatusBadRequest
)
return
}
requestState
:=
request
.
Form
.
Get
(
"state"
)
if
requestState
!=
state
.
String
()
{
errorChannel
<-
fmt
.
Errorf
(
"state invalid, requestState: %v, authState:%v"
,
requestState
,
state
.
String
())
http
.
Error
(
writer
,
fmt
.
Sprintf
(
"state invalid, requestState: %v, authState:%v"
,
requestState
,
state
.
String
()),
http
.
StatusBadRequest
)
errorMsg
:=
fmt
.
Sprintf
(
"state invalid, requestState: %v, authState:%v"
,
requestState
,
state
.
String
())
errorChannel
<-
fmt
.
Errorf
(
errorMsg
)
http
.
Error
(
writer
,
errorMsg
,
http
.
StatusBadRequest
)
return
}
code
:=
request
.
Form
.
Get
(
"code"
)
if
code
==
""
{
errorChannel
<-
fmt
.
Errorf
(
"code not found"
)
http
.
Error
(
writer
,
"code not found"
,
http
.
StatusBadRequest
)
errorMsg
:=
"code not found"
errorChannel
<-
fmt
.
Errorf
(
errorMsg
)
http
.
Error
(
writer
,
errorMsg
,
http
.
StatusBadRequest
)
return
}
token
,
err
:=
config
.
Exchange
(
context
.
Background
(),
code
)
if
err
!=
nil
{
errorChannel
<-
fmt
.
Errorf
(
"failed to create token, err: %v"
,
err
)
http
.
Error
(
writer
,
fmt
.
Sprintf
(
"failed to create token, err: %v"
,
err
),
http
.
StatusInternalServerError
)
errorMsg
:=
fmt
.
Sprintf
(
"failed to create token, err: %v"
,
err
)
errorChannel
<-
fmt
.
Errorf
(
errorMsg
)
http
.
Error
(
writer
,
errorMsg
,
http
.
StatusInternalServerError
)
return
}
...
...
This diff is collapsed.
Click to expand it.
cli/cmd/config.go
+
1
-
1
View file @
dac1b4fd
...
...
@@ -33,7 +33,7 @@ var configCmd = &cobra.Command{
}
else
{
template
,
err
:=
uiUtils
.
PrettyYaml
(
configWithDefaults
)
if
err
!=
nil
{
logger
.
Log
.
Errorf
(
"Failed converting config with defaults to
json
, err: %v"
,
err
)
logger
.
Log
.
Errorf
(
"Failed converting config with defaults to
yaml
, err: %v"
,
err
)
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help