forked from Qortal/qortal
Added POST /render/authorize/{resourceId} endpoint
This allows an entire registered name to be preauthorized, therefore allowing for instance a website to automatically request other resources from the same author, such as videos.
This commit is contained in:
parent
75d9347d23
commit
17fe94fa46
@ -95,6 +95,16 @@ public class RenderResource {
|
|||||||
return "Unable to generate preview URL";
|
return "Unable to generate preview URL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/authorize/{resourceId}")
|
||||||
|
@SecurityRequirement(name = "apiKey")
|
||||||
|
public boolean authorizeResource(@PathParam("resourceId") String resourceId) {
|
||||||
|
Security.checkApiCallAllowed(request);
|
||||||
|
ArbitraryDataResource resource = new ArbitraryDataResource(resourceId, null, null, null);
|
||||||
|
ArbitraryDataRenderManager.getInstance().addToAuthorizedResources(resource);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("authorize/{service}/{resourceId}")
|
@Path("authorize/{service}/{resourceId}")
|
||||||
@SecurityRequirement(name = "apiKey")
|
@SecurityRequirement(name = "apiKey")
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package org.qortal.controller.arbitrary;
|
package org.qortal.controller.arbitrary;
|
||||||
|
|
||||||
import org.qortal.arbitrary.ArbitraryDataFile;
|
|
||||||
import org.qortal.arbitrary.ArbitraryDataResource;
|
import org.qortal.arbitrary.ArbitraryDataResource;
|
||||||
import org.qortal.arbitrary.misc.Service;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -31,9 +29,16 @@ public class ArbitraryDataRenderManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(ArbitraryDataResource resource) {
|
public boolean isAuthorized(ArbitraryDataResource resource) {
|
||||||
|
ArbitraryDataResource broadResource = new ArbitraryDataResource(resource.getResourceId(), null, null, null);
|
||||||
|
|
||||||
for (ArbitraryDataResource authorizedResource : this.authorizedResources) {
|
for (ArbitraryDataResource authorizedResource : this.authorizedResources) {
|
||||||
if (authorizedResource != null && resource != null) {
|
if (authorizedResource != null && resource != null) {
|
||||||
if (Objects.equals(authorizedResource.toString(), resource.toString())) {
|
// Check for exact match
|
||||||
|
if (Objects.equals(authorizedResource.getUniqueKey(), resource.getUniqueKey())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Check for a broad authorization (which applies to all services and identifiers under an authorized name)
|
||||||
|
if (Objects.equals(authorizedResource.getUniqueKey(), broadResource.getUniqueKey())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user