diff --git a/v1/Application.cfc b/v1/Application.cfc index f8bbd8b..1ac189f 100644 --- a/v1/Application.cfc +++ b/v1/Application.cfc @@ -57,7 +57,7 @@ //variables.framework.docs={}; variables.framework.docs.APIName="svc-api"; - variables.framework.docs.APIVersion="0.228"; /*$ git config --global --unset user.password*/ + variables.framework.docs.APIVersion="0.227"; /*$ git config --global --unset user.password*/ variables.framework.globalHeaders = structNew(); variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location"; @@ -336,14 +336,48 @@ return true; - +//////////////////////////////////////////////////////////////////////////// + //ensure https because of basic authentication + if (!lcase(request.config.environment) == "development"){ + if (!cgi.server_port_secure) { return newRepresentation().noData().withStatus("403.4", "SSL Required");} + } + + request.usr_id=request.UNDEFINED_USR_ID; + + if (checkAuth()) {return true;} + + //return representationOf(arguments.headers); + //return representationOf(arguments.cfc); + var authToken=""; + if (structKeyExists(arguments.headers,"x-auth-token")) {authToken=structFind(arguments.headers,"x-auth-token");} + var issuedFor=""; + if (structKeyExists(arguments.headers,"x-issued-for")) {issuedFor=structFind(arguments.headers,"x-issued-for");} + if (validatePin(authToken,issuedFor, arguments.verb, arguments.cfc)) return true; //side effect: sets request.usr_id! + + if (!validateCredentials(getBasicAuthCredentials())) { + return newRepresentation().noData().withStatus("401", "Invalid Credentials").withHeaders({"WWW-Authenticate":"Basic realm=mms-api"}); + } + return true; } + //private function validateToken(token){ return false; } + //refactoring required + private function validateCredentials(credentials) {//return true; + if (arguments.credentials.username == "medved" /*AND credentials.password == "ghtdtlrhjcfdxtu!Y"*/) { + request.usr_id=-3; + return true; + } + return false; + } - + + diff --git a/v1/resources/instance_operation_default.cfc b/v1/resources/instance_operation_default.cfc index e584569..2ceb77b 100644 --- a/v1/resources/instance_operation_default.cfc +++ b/v1/resources/instance_operation_default.cfc @@ -80,7 +80,6 @@ >p.func p.ref_svc_id p.is_required - p.is_hidden p.default_value p.default_compute p.regex @@ -171,7 +170,6 @@ ,sp.depends_on_cfs_params ,sp.expression ,sp.is_required - ,sp.is_hidden ,sp.descr ,sp.man ,sp.default_value @@ -241,7 +239,6 @@ "descr":"#local.qSubparam.descr#", "defaultValue":"#def#", "isRequired":#request.castToBool(local.qSubparam.is_required)#, - "isHidden":#request.castToBool(local.qSubparam.is_hidden)#, "isSensitive":#request.castToBool(local.qSubparam.is_sensitive)#, "refSvcId":#local.qSubparam.ref_svc_id#, "uniqueScope":"#local.qSubparam.unique_scope#", diff --git a/v1/resources/new 1.txt b/v1/resources/new 1.txt deleted file mode 100644 index 13a0086..0000000 --- a/v1/resources/new 1.txt +++ /dev/null @@ -1,52 +0,0 @@ -drop table if exists vmreports.vm_gpu; -create table vmreports.vm ( - "Name" varchar(255) NULL, - "ClientID" varchar(255) NULL, --WZ - "VCD" varchar(255) NULL, --vcloud - "Org" varchar(255) NULL, - "OrgVDC" varchar(255) NULL, - "vCenter" varchar(255) NULL, - "GPU" jsonb NULL, - "OrgStatus" varchar(255) NULL, - "Object_UUID" uuid NOT NULL, - ts timestamptz NOT NULL - ,CONSTRAINT PK_vm_gpu PRIMARY KEY (ts, "Object_UUID") -); -grant all on vmreports.vm to nifi; - -/* -{ -"type": "record", -"name": "vmreports.vm_gpu", -"namespace": "org.apache.nifi", -"fields": [ - {"name":"Object_UUID", "type":{"type": "string", "logicalType": "uuid"}}, - {"name":"ts","type":{"type": "long", "logicalType": "local-timestamp-millis"}}, - - {"name":"Name", "type":["string" ,"null"]}, - {"name":"ClientID", "type":["string" ,"null"]}, - {"name":"VCD", "type":["string" ,"null"]}, - {"name":"Org", "type":["string" ,"null"]}, - {"name":"OrgVDC", "type":["string" ,"null"]}, - {"name":"vCenter", "type":["string" ,"null"]}, - {"name":"GPU", "type":["string" ,"null"]}, - {"name":"OrgStatus", "type":["string" ,"null"]} -] -} -*/ - -/* -{ - "*": { - "objId":"[&1].Name", - "1":"[&1].ClientID", - "2":"[&1].VCD", - "3":"[&1].Org", - "4":"[&1].OrgVDC", - "5":"[&1].vCenter", - "6":"[&1].GPU", - "7":"[&1].OrgStatus", - "objUUID":"[&1].Object_UUID" - } - } -*/ \ No newline at end of file diff --git a/v1/resources/svc_operation.cfc b/v1/resources/svc_operation.cfc index f37bb2a..e5dec6b 100644 --- a/v1/resources/svc_operation.cfc +++ b/v1/resources/svc_operation.cfc @@ -39,7 +39,6 @@ ((isArray(x) OR isEmpty(x))? x : listToArray(x))#>p.value_list p.ref_svc_id p.is_required - p.is_hidden p.default_value p.default_compute p.func