Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
luna
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
luna
Commits
5e207ee9
Commit
5e207ee9
authored
Mar 12, 2018
by
zheng liu
Browse files
Options
Browse Files
Download
Plain Diff
Merged in dev (pull request #78)
Dev
parents
44c6dd2d
d6d3490e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
14 deletions
+33
-14
app.service.ts
src/app/app.service.ts
+11
-2
guacamole.component.ts
src/app/elements/guacamole/guacamole.component.ts
+22
-12
No files found.
src/app/app.service.ts
View file @
5e207ee9
...
...
@@ -70,10 +70,11 @@ export class HttpService {
return
this
.
http
.
get
<
Array
<
HostGroup
>>
(
'/api/perms/v1/user/nodes-assets/'
);
}
get_guacamole_token
(
user_id
:
string
)
{
get_guacamole_token
(
user_id
:
string
,
authToken
:
string
)
{
const
body
=
new
HttpParams
()
.
set
(
'username'
,
user_id
)
.
set
(
'password'
,
'jumpserver'
);
.
set
(
'password'
,
'jumpserver'
)
.
set
(
'asset_token'
,
authToken
);
// {
// "authToken": "xxxxxxx",
// "username": "xxxxxx",
...
...
@@ -127,6 +128,14 @@ export class HttpService {
return
this
.
http
.
get
(
'/api/terminal/v1/sessions/'
+
token
+
'/replay'
);
}
get_user_id_from_token
(
token
:
string
)
{
const
params
=
new
HttpParams
()
.
set
(
'user-only'
,
'1'
)
.
set
(
'token'
,
token
);
return
this
.
http
.
get
(
'/api/users/v1/connection-token/'
,
{
params
:
params
});
}
}
@
Injectable
()
...
...
src/app/elements/guacamole/guacamole.component.ts
View file @
5e207ee9
...
...
@@ -31,19 +31,29 @@ export class ElementGuacamoleComponent implements OnInit {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
if
(
this
.
token
)
{
this
.
userid
=
this
.
_localStorage
.
get
(
'user'
);
this
.
_http
.
get_guacamole_token
(
this
.
userid
).
subscribe
(
data
=>
{
DataStore
.
guacamole_token
=
data
[
'authToken'
];
this
.
_http
.
guacamole_token_add_asset
(
this
.
token
,
data
[
'authToken'
]).
subscribe
(
data2
=>
{
this
.
_logger
.
debug
(
data
);
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
data2
[
'result'
]
+
'?token='
+
data
[
'authToken'
];
},
error2
=>
{
this
.
_logger
.
error
(
error2
);
if
(
this
.
userid
)
{
this
.
_http
.
get_guacamole_token
(
this
.
userid
,
this
.
token
).
subscribe
(
data
=>
{
DataStore
.
guacamole_token
=
data
[
'authToken'
];
this
.
_http
.
guacamole_token_add_asset
(
this
.
token
,
data
[
'authToken'
]).
subscribe
(
data2
=>
{
this
.
_logger
.
debug
(
data
);
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
data2
[
'result'
]
+
'?token='
+
data
[
'authToken'
];
},
error2
=>
{
this
.
_logger
.
error
(
error2
);
}
);
});
}
else
{
this
.
_http
.
get_user_id_from_token
(
this
.
token
)
.
subscribe
(
data
=>
{
this
.
_localStorage
.
set
(
'user'
,
data
[
'user'
]);
}
);
});
}
}
else
{
const
base
=
window
.
btoa
(
this
.
host
.
id
+
'
\
0'
+
'c'
+
'
\
0'
+
'jumpserver'
);
if
(
environment
.
production
)
{
...
...
@@ -57,7 +67,7 @@ export class ElementGuacamoleComponent implements OnInit {
}
);
}
else
{
this
.
_http
.
get_guacamole_token
(
User
.
id
).
subscribe
(
this
.
_http
.
get_guacamole_token
(
User
.
id
,
''
).
subscribe
(
data
=>
{
// /guacamole/client will redirect to http://guacamole/#/client
DataStore
.
guacamole_token
=
data
[
'authToken'
];
...
...
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