Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
pve-manager
Commits
5a885216
Commit
5a885216
authored
Apr 28, 2014
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API2Client: split out login code
parent
e24a91c1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
18 deletions
+28
-18
API2Client.pm
PVE/API2Client.pm
+28
-18
No files found.
PVE/API2Client.pm
View file @
5a885216
...
...
@@ -41,31 +41,20 @@ sub update_ticket {
$self
->
{
cookie_jar
}
->
set_cookie
(
0
,
'
PVEAuthCookie
',
$ticket
,
'
/
',
$domain
);
}
sub
call
{
my
(
$self
,
$method
,
$path
,
$param
)
=
@_
;
#print "wrapper called\n";
my
$ticket
;
my
$ua
=
$self
->
{
useragent
};
my
$cj
=
$self
->
{
cookie_jar
};
sub
login
{
my
(
$self
)
=
@_
;
$cj
->
scan
(
sub
{
my
(
$version
,
$key
,
$val
)
=
@_
;
$ticket
=
$val
if
$key
eq
'
PVEAuthCookie
';
});
if
(
!
$ticket
&&
$self
->
{
username
}
&&
$self
->
{
password
})
{
my
$uri
=
URI
->
new
();
$uri
->
scheme
(
$self
->
{
protocol
});
$uri
->
host
(
$self
->
{
host
});
$uri
->
port
(
$self
->
{
port
});
$uri
->
path
('
/api2/json/access/ticket
');
my
$ua
=
$self
->
{
useragent
};
my
$response
=
$ua
->
post
(
$uri
,
{
username
=>
$self
->
{
username
}
,
password
=>
$self
->
{
password
}
});
username
=>
$self
->
{
username
}
||
'
unknown
'
,
password
=>
$self
->
{
password
}
||
''
});
if
(
!
$response
->
is_success
)
{
die
$response
->
status_line
.
"
\n
";
...
...
@@ -75,6 +64,27 @@ sub call {
$self
->
update_ticket
(
$data
->
{
data
}
->
{
ticket
});
$self
->
{
csrftoken
}
=
$data
->
{
data
}
->
{
CSRFPreventionToken
};
return
$data
;
}
sub
call
{
my
(
$self
,
$method
,
$path
,
$param
)
=
@_
;
#print "wrapper called\n";
my
$ticket
;
my
$ua
=
$self
->
{
useragent
};
my
$cj
=
$self
->
{
cookie_jar
};
$cj
->
scan
(
sub
{
my
(
$version
,
$key
,
$val
)
=
@_
;
$ticket
=
$val
if
$key
eq
'
PVEAuthCookie
';
});
if
(
!
$ticket
&&
$self
->
{
username
}
&&
$self
->
{
password
})
{
$self
->
login
();
}
my
$uri
=
URI
->
new
();
...
...
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