Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
60d7d9c6
Unverified
Commit
60d7d9c6
authored
Feb 04, 2019
by
Torkel Ödegaard
Committed by
GitHub
Feb 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15181 from marefr/fix_ping_unauthorized
auth: /api/login/ping fixes
parents
d4ecba52
cfd8eb51
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
13 deletions
+28
-13
pkg/api/api.go
+2
-2
public/app/core/services/backend_srv.ts
+26
-11
No files found.
pkg/api/api.go
View file @
60d7d9c6
...
...
@@ -108,8 +108,8 @@ func (hs *HTTPServer) registerRoutes() {
r
.
Get
(
"/api/snapshots-delete/:deleteKey"
,
Wrap
(
DeleteDashboardSnapshotByDeleteKey
))
r
.
Delete
(
"/api/snapshots/:key"
,
reqEditorRole
,
Wrap
(
DeleteDashboardSnapshot
))
// api renew session based on
remember
cookie
r
.
Get
(
"/api/login/ping"
,
quota
(
"session"
),
hs
.
LoginAPIPing
)
// api renew session based on cookie
r
.
Get
(
"/api/login/ping"
,
quota
(
"session"
),
Wrap
(
hs
.
LoginAPIPing
)
)
// authed api
r
.
Group
(
"/api"
,
func
(
apiRoute
routing
.
RouteRegister
)
{
...
...
public/app/core/services/backend_srv.ts
View file @
60d7d9c6
import
_
from
'lodash'
;
import
coreModule
from
'app/core/core_module'
;
import
appEvents
from
'app/core/app_events'
;
import
config
from
'app/core/config'
;
import
{
DashboardModel
}
from
'app/features/dashboard/state/DashboardModel'
;
export
class
BackendSrv
{
...
...
@@ -103,10 +104,17 @@ export class BackendSrv {
err
=>
{
// handle unauthorized
if
(
err
.
status
===
401
&&
this
.
contextSrv
.
user
.
isSignedIn
&&
firstAttempt
)
{
return
this
.
loginPing
().
then
(()
=>
{
options
.
retry
=
1
;
return
this
.
request
(
options
);
});
return
this
.
loginPing
()
.
then
(()
=>
{
options
.
retry
=
1
;
return
this
.
request
(
options
);
})
.
catch
(
err
=>
{
if
(
err
.
status
===
401
)
{
window
.
location
.
href
=
config
.
appSubUrl
+
'/logout'
;
throw
err
;
}
});
}
this
.
$timeout
(
this
.
requestErrorHandler
.
bind
(
this
,
err
),
50
);
...
...
@@ -184,13 +192,20 @@ export class BackendSrv {
// handle unauthorized for backend requests
if
(
requestIsLocal
&&
firstAttempt
&&
err
.
status
===
401
)
{
return
this
.
loginPing
().
then
(()
=>
{
options
.
retry
=
1
;
if
(
canceler
)
{
canceler
.
resolve
();
}
return
this
.
datasourceRequest
(
options
);
});
return
this
.
loginPing
()
.
then
(()
=>
{
options
.
retry
=
1
;
if
(
canceler
)
{
canceler
.
resolve
();
}
return
this
.
datasourceRequest
(
options
);
})
.
catch
(
err
=>
{
if
(
err
.
status
===
401
)
{
window
.
location
.
href
=
config
.
appSubUrl
+
'/logout'
;
throw
err
;
}
});
}
// populate error obj on Internal Error
...
...
Write
Preview
Markdown
is supported
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