Skip to content

Commit 1e89d15

Browse files
author
Blair McKenzie
committed
revisions and fixes for api handling
1 parent 5400a5f commit 1e89d15

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

packages/api/base.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ component {
222222
}
223223

224224
public void function updateObject(required struct stObject, required struct stUpdate) {
225-
var swaggerDef = application.fc.lib.api.swagger[request.req.handler.api].definitions[arguments.stObject.typename & "Update"].schema.properties;
225+
var swaggerDef = application.fc.lib.api.swagger[request.req.handler.api].definitions[arguments.stObject.typename & "Update"].properties;
226226
var key = "";
227227
var stItem = {};
228228
var o = application.fapi.getContentType(typename=arguments.stObject.typename);

packages/lib/api.cfc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ component {
642642
"authentication" = "statelesskey",
643643
"groups" = application.security.userdirectories[listLast(stProfile.userdirectory)].getUserGroups(listDeleteAt(stProfile.username, listLen(stProfile.username, "_"), "_"))
644644
};
645+
arguments.req.user.roles = application.security.factory.role.groupsToRoles(arrayToList(arguments.req.user.groups));
645646
}
646647

647648
return [];
@@ -654,7 +655,8 @@ component {
654655
arguments.req.user = {
655656
"id" = application.security.getCurrentUserID(),
656657
"profile" = session.dmProfile,
657-
"authentication" = "session"
658+
"authentication" = "session",
659+
"roles" = application.security.getCurrentRoles()
658660
};
659661
}
660662

@@ -743,6 +745,10 @@ component {
743745
arguments.permission = listLast(arguments.permission, ":");
744746
}
745747

748+
if (arguments.permission eq "authenticated") {
749+
return listFindNoCase("public,key,statelesskey,basic,session", arguments.req.authentication) gt 0;
750+
}
751+
746752
switch (arguments.req.authentication) {
747753
case "public":
748754
return true;

packages/lib/swagger.cfc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ component {
164164
}
165165
}
166166

167+
for (typename in arguments.typenames) {
168+
arguments.swagger.definitions["#typename#"] = getSwaggerDefinition(typename=typename, forUpdate=false);
169+
arguments.swagger.definitions["#typename#Update"] = getSwaggerDefinition(typename=typename, forUpdate=true);
170+
}
171+
167172
if (expandTypename) {
168173
for (typename in arguments.typenames) {
169174
altMethod = duplicate(methodOut);
@@ -198,10 +203,6 @@ component {
198203

199204
arguments.swagger.paths[altMethod["x-path"]][altMethod["x-method"]] = altMethod;
200205

201-
if (listFindNoCase("CREATE,PUT,POST", altMethod["x-method"]) and not structKeyExists(arguments.swagger.definitions, "#typename#Update")) {
202-
arguments.swagger.definitions["#typename#Update"] = getSwaggerDefinition(typename=typename, forUpdate=true);
203-
}
204-
205206
structDelete(altMethod, "x-path");
206207
structDelete(altMethod, "x-method");
207208
}
@@ -371,7 +372,7 @@ component {
371372
var prop = "";
372373

373374
if (structKeyExists(o, "getSwaggerDefinition")) {
374-
return o.getSwaggerDefinition(typename=arguments.typename);
375+
return o.getSwaggerDefinition(argumentCollection=arguments);
375376
}
376377

377378
if (not arguments.forUpdate) {

webskin/configAPI/displayIntroductionV1.cfm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ The following authentication methods are supported:
2020
<cfoutput>- API key - include the API key in the request `Authentication` header.
2121
</cfoutput>
2222
</cfif>
23+
<cfif listFindNoCase(application.fapi.getConfig("api", "authentication"), "statelesskey")>
24+
<cfoutput>- Stateless API key - `application.fc.lib.api.getStatelessAPIKey(username)` will return a temporary key to include in the request `Authentication` header.
25+
</cfoutput>
26+
</cfif>
2327
<cfif listFindNoCase(application.fapi.getConfig("api", "authentication"), "basic")>
2428
<cfoutput>- Basic HTTP - pass your FarCry credentials with the request in the `Authentication` header.
2529
</cfoutput>

0 commit comments

Comments
 (0)