Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
libocci
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
617b2288
authored
Apr 09, 2017
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BME login method
parent
b872ee23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletions
+36
-1
occisession.cpp
+33
-1
occisession.h
+3
-0
No files found.
occisession.cpp
View file @
617b2288
...
...
@@ -24,6 +24,9 @@
#include "occisession.h"
#include <gq/Document.h>
#include <gq/Node.h>
using
std
::
string
;
using
nlohmann
::
json
;
using
namespace
OcciClient
;
...
...
@@ -40,7 +43,7 @@ void OcciSession::setCsrfTokenHeader(){
this
->
connection
->
AppendHeader
(
"X-CSRFToken"
,
csrftoken
);
}
OcciSession
::
OcciSession
(
const
char
*
url
,
bool
insecure
,
bool
csrf
){
OcciSession
::
OcciSession
(
const
char
*
url
,
bool
insecure
,
bool
csrf
)
:
url
(
url
)
{
RestClient
::
init
();
this
->
connection
=
new
RestClient
::
Connection
(
url
);
if
(
insecure
)
{
...
...
@@ -111,6 +114,35 @@ void OcciSession::circleOcciLogin(string username, string password){
post
(
"login/"
,
json
::
parse
(
body
));
}
void
OcciSession
::
BMELogin
(
string
username
,
string
password
,
bool
insecure
){
std
::
string
&
sp_url
=
url
;
auto
con
=
new
RestClient
::
Connection
(
""
);
if
(
insecure
)
{
con
->
SetHostVerify
(
false
);
con
->
SetPeerVerify
(
false
);
}
con
->
FollowRedirects
(
true
);
auto
r
=
con
->
get
(
sp_url
+
"/saml2/login/"
);
auto
idp_auth_url
=
con
->
GetInfo
().
lastRequest
.
effectiveUrl
;
std
::
string
body
=
"j_username="
+
username
+
"&j_password="
+
password
;
con
->
setCookies
(
r
.
cookies
);
r
=
con
->
post
(
idp_auth_url
,
body
);
CDocument
doc
;
doc
.
parse
(
r
.
body
.
c_str
());
CSelection
c
=
doc
.
find
(
"input[name=RelayState]"
);
auto
RelayState
=
c
.
nodeAt
(
0
).
attribute
(
"value"
);
c
=
doc
.
find
(
"input[name=SAMLResponse]"
);
auto
SAMLResponse
=
c
.
nodeAt
(
0
).
attribute
(
"value"
);
RestClient
::
PostData
data
;
data
[
"RelayState"
]
=
RelayState
;
data
[
"SAMLResponse"
]
=
SAMLResponse
;
con
->
clearCookies
();
r
=
con
->
post
(
sp_url
+
"/saml2/acs/"
,
data
);
this
->
connection
->
setCookies
(
r
.
cookies
);
}
json
OcciSession
::
queryInterface
(){
return
get
(
"-/"
);
}
occisession.h
View file @
617b2288
...
...
@@ -34,6 +34,7 @@ namespace OcciClient {
private
:
std
::
string
url
;
RestClient
::
Connection
*
connection
=
nullptr
;
bool
csrftokenRequired
=
false
;
std
::
string
csrfuri
;
...
...
@@ -58,6 +59,8 @@ namespace OcciClient {
void
circleOcciLogin
(
std
::
string
username
,
std
::
string
password
);
void
BMELogin
(
std
::
string
username
,
std
::
string
password
,
bool
insecure
=
false
);
nlohmann
::
json
queryInterface
();
};
}
...
...
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