Removing old ucentral. properties to openwifi.

This commit is contained in:
stephb9959
2021-09-02 18:55:37 -07:00
parent 2d2204f06d
commit c75782cb38
3 changed files with 6 additions and 31 deletions

View File

@@ -26,8 +26,6 @@ namespace OpenWifi{
if (!IsAuthorized(Request, Response))
return;
std::cout << "Email:" << UserInfo_.userinfo.email << std::endl;
ParseParameters(Request);
if(Request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET)
DoGet(Request, Response);
@@ -200,13 +198,9 @@ namespace OpenWifi{
return;
}
std::cout << "Updating: " << LocalObject.info.name << std::endl;
Poco::JSON::Parser IncomingParser;
auto RawObject = IncomingParser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
if(RawObject->has("notes")) {
std::cout << "email" << UserInfo_.userinfo.email << std::endl;
std::cout << "id" << UserInfo_.userinfo.Id << std::endl;
SecurityObjects::append_from_json(RawObject, UserInfo_.userinfo, LocalObject.info.notes);
}

View File

@@ -355,19 +355,12 @@ namespace OpenWifi {
bool RESTAPIHandler::IsAuthorized(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
std::cout << "Session token:" << SessionToken_ << std::endl;
if(Internal_) {
return Daemon()->IsValidAPIKEY(Request);
} else {
if (SessionToken_.empty()) {
try {
Poco::Net::OAuth20Credentials Auth(Request);
std::cout << "Scheme: " << Auth.getScheme() << std::endl;
for(const auto &i:Request) {
std::cout << "1" << i.first << " = " << i.second << std::endl;
}
if (Auth.getScheme() == "Bearer") {
SessionToken_ = Auth.getBearerToken();
}
@@ -378,7 +371,6 @@ namespace OpenWifi {
#ifdef TIP_SECURITY_SERVICE
if (AuthService()->IsAuthorized(Request, SessionToken_, UserInfo_)) {
#else
std::cout << "Session token:" << SessionToken_ << std::endl;
if (AuthClient()->IsAuthorized(Request, SessionToken_, UserInfo_)) {
#endif
return true;
@@ -389,17 +381,6 @@ namespace OpenWifi {
}
}
/*
bool RESTAPIHandler::ValidateAPIKey(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
auto Key = Request.get("X-API-KEY", "");
if (Key.empty())
return false;
return true;
}
*/
void RESTAPIHandler::ReturnObject(Poco::Net::HTTPServerRequest &Request, Poco::JSON::Object &Object,
Poco::Net::HTTPServerResponse &Response) {
PrepareResponse(Request, Response);

View File

@@ -20,10 +20,10 @@ then
exit 1
fi
if [[ "${UCENTRALSEC}" == "" ]]
if [[ "${OWSEC}" == "" ]]
then
echo "You must set the variable UCENTRALSEC in order to use this script. Something like"
echo "UCENTRALSEC=security.isp.com:16001"
echo "You must set the variable OWSEC in order to use this script. Something like"
echo "OWSEC=security.isp.com:16001"
exit 1
fi
@@ -41,7 +41,7 @@ browser=""
login() {
payload="{ \"userId\" : \"$username\" , \"password\" : \"$password\" }"
token=$(curl ${FLAGS} -X POST -H "Content-Type: application/json" -d "$payload" "https://${UCENTRALSEC}/api/v1/oauth2" | jq -r '.access_token')
token=$(curl ${FLAGS} -X POST -H "Content-Type: application/json" -d "$payload" "https://${OWSEC}/api/v1/oauth2" | jq -r '.access_token')
if [[ "${token}" == "" ]]
then
@@ -73,7 +73,7 @@ findbrowser() {
}
setprov() {
curl ${FLAGS} -X GET "https://${UCENTRALSEC}/api/v1/systemEndpoints" \
curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/systemEndpoints" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
# jq < ${result_file}
@@ -106,7 +106,7 @@ setprov() {
logout() {
curl ${FLAGS} -X DELETE -H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
"https://${UCENTRALSEC}/api/v1/oauth2/${token}"
"https://${OWSEC}/api/v1/oauth2/${token}"
rm -rf token.json
}