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
8f6626e8
Commit
8f6626e8
authored
Mar 19, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mssql: encrypt password in database
parent
6044b3ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
pkg/tsdb/mssql/mssql.go
+21
-10
public/app/plugins/datasource/mssql/partials/config.html
+7
-2
No files found.
pkg/tsdb/mssql/mssql.go
View file @
8f6626e8
...
...
@@ -38,27 +38,38 @@ func NewMssqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
MacroEngine
:
NewMssqlMacroEngine
(),
}
cnnstr
:=
generateConnectionString
(
datasource
)
endpoint
.
log
.
Debug
(
"getEngine"
,
"connection"
,
cnnstr
)
if
err
:=
endpoint
.
sqlEngine
.
InitEngine
(
"mssql"
,
datasource
,
cnnstr
);
err
!=
nil
{
return
nil
,
err
}
return
endpoint
,
nil
}
func
generateConnectionString
(
datasource
*
models
.
DataSource
)
string
{
password
:=
""
for
key
,
value
:=
range
datasource
.
SecureJsonData
.
Decrypt
()
{
if
key
==
"password"
{
password
=
value
break
}
}
hostParts
:=
strings
.
Split
(
datasource
.
Url
,
":"
)
if
len
(
hostParts
)
<
2
{
hostParts
=
append
(
hostParts
,
"1433"
)
}
server
,
port
:=
hostParts
[
0
],
hostParts
[
1
]
endpoint
.
log
.
Debug
(
"cnnstr"
,
"hostParts len"
,
len
(
hostParts
))
cnnstr
:=
fmt
.
Sprintf
(
"server=%s;port=%s;database=%s;user id=%s;password=%s;"
,
return
fmt
.
Sprintf
(
"server=%s;port=%s;database=%s;user id=%s;password=%s;"
,
server
,
port
,
datasource
.
Database
,
datasource
.
User
,
datasource
.
P
assword
,
p
assword
,
)
endpoint
.
log
.
Debug
(
"getEngine"
,
"connection"
,
cnnstr
)
if
err
:=
endpoint
.
sqlEngine
.
InitEngine
(
"mssql"
,
datasource
,
cnnstr
);
err
!=
nil
{
return
nil
,
err
}
return
endpoint
,
nil
}
// Query is the main function for the MssqlQueryEndpoint
...
...
public/app/plugins/datasource/mssql/partials/config.html
View file @
8f6626e8
...
...
@@ -17,9 +17,14 @@
<span
class=
"gf-form-label width-7"
>
User
</span>
<input
type=
"text"
class=
"gf-form-input"
ng-model=
'ctrl.current.user'
placeholder=
"user"
></input>
</div>
<div
class=
"gf-form max-width-15"
>
<div
class=
"gf-form max-width-15"
ng-if=
"!ctrl.current.secureJsonFields.password"
>
<span
class=
"gf-form-label width-7"
>
Password
</span>
<input
type=
"password"
class=
"gf-form-input"
ng-model=
'ctrl.current.secureJsonData.password'
placeholder=
"password"
></input>
</div>
<div
class=
"gf-form max-width-19"
ng-if=
"ctrl.current.secureJsonFields.password"
>
<span
class=
"gf-form-label width-7"
>
Password
</span>
<input
type=
"password"
class=
"gf-form-input"
ng-model=
'ctrl.current.password'
placeholder=
"password"
></input>
<input
type=
"text"
class=
"gf-form-input"
disabled=
"disabled"
value=
"configured"
>
<a
class=
"btn btn-secondary gf-form-btn"
href=
"#"
ng-click=
"ctrl.current.secureJsonFields.password = false"
>
reset
</a>
</div>
</div>
</div>
...
...
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