Jump to content

thomasaull

Members
  • Content Count

    79
  • Joined

  • Last visited

  • Days Won

    2

thomasaull last won the day on September 19 2018

thomasaull had the most liked content!

Community Reputation

105 Excellent

1 Follower

About thomasaull

  • Rank
    Full Member

Contact Methods

  • Website URL
    www.thomasaull.de

Profile Information

  • Location
    Würzburg, Germany

Recent Profile Visitors

1,686 profile views
  1. Hi @Orkun, at the moment there is not built-in way for such a use case. However I guess it's really easy to do with a ProcessWire Hook which can be independet of the API, you'd just need to run the hook on the endpoint-url and check the IP with PHP there. If you want to restrict access to specific routes of the API only, I'd probably run the same checks in the endpoint function.
  2. @Andy I think for the getallheaders() function it'd make sense to keep the old way aswell and just search in both for the Authorization Header (If I remember correctly, the getallheaders() function wasn't available in all environments. In case you create a PR we can discuss the details there 🙂 Basically you need to fork the repository, push your changes and then create a PR on the github website
  3. @Andy I'd be awesome if you could create a Pull Request for these changes 🙏: https://github.com/thomasaull/RestApi/pulls
  4. @Andy Uh, the first time I'm seeing this page. Where can I access it in the ProcessWire Backend? Is the module otherwise working for you? Regarding your question about file uploads: The module itself does not has an implementation for this case, basically it provides just a wrapper for your own functions. So in theory you should be able to create a route for a file upload and have your own function to accept the file and store it on the server. If you google "Processwire file upload" you should find some examples to get you started. I'm writing "in theory" because I haven't done it myself yet. If this approach fails, we can figure out what needs be changed in the module itself.
  5. Ah sorry, I didn't catch that. Can you check in the `headers` Tab how the Header is actually set? I did check everything with Insomnia on Saturday and it worked for me … Regarding saving the JWT Token: I have been saving it in local storge, but this is considered unsafe, since third party scripts could access it (if you do not use any third party scripts, this might not be an issue). So I guess the best thing is to store it in a cookie.
  6. @Orkun Please check the documentation:https://github.com/thomasaull/RestApi#authorization-jwt You need to set the JWT as Header name "Authorization"
  7. Hey @Orkun, thanks, I'm really glad this module is useful for you! The problem you run into, results from code I just copied from @LostKobrakai I think (Thx for investigating btw!). I'm not sure if it's a good way to forward your parameter like this and I guess there's a good reason this sanitizer is in place. Imagine a user would input an email like this `user?foo=bar@test.de`, I guess it would break the API since `foo` would be interpretet as a GET Variable. A couple of suggestions: Use a post request and put the email in the post body URL encode your request url, this way the email *should* come through Maybe other people have some input on this issue aswell…?
  8. @calago I just tried to reproduce this issue with a new installation of ProcessWire: Install ProcessWire with blank profile Install RestApi Module run `api/test` => `test successful` change endpoint to `api-v2` run `api/test` => 404 Error run `api-v2/test` => `test successful` comment out all routes in `Routes.php` and run `api-v2/test` => 500 Server error (this is expected I guess) Add new file `/site/api/AnotherExample.php`, change `Routes.php` to this: <?php namespace ProcessWire; require_once wire('config')->paths->RestApi . "vendor/autoload.php"; require_once wire('config')->paths->RestApi . "RestApiHelper.php"; require_once __DIR__ . "/AnotherExample.php"; $routes = [ ['GET', 'other-test', AnotherExample::class, 'other'], ]; and run `api-v2/other-test` => `another example` So basically everything is working perfectly fine on my end. I guess it's something related to your environment/installation/modules… Hard to debug, if you need more help maybe provide a test repo?
  9. Mmmhh really weird. Can‘t spot anything wrong on first sight. Can you reproduce this problem on a fresh install without any other plugins? Are you using anything cache related (Pro-Cache maybe?)
  10. @calago can you provide your "routes.php" aswell as the file with the endpoint function you're calling in your route?
  11. Hi @louisstephens, thanks for the kind words! I remember that I had the exact same problem as you once, but I can't remember what the problem or the solution actually was. Afaik it was not an issue with the module itself but with how ProcessWire handles image paths. I think I did some digging by creating a new template and return the image path there — maybe you could try that and let me know about the result. Also you could try to experiment mit $page->of (output formatting). This might have an effect on that matter aswell.
  12. @lemgrago I think at the moment the module only supports a single depth of grouping. I did a quick check and it doesn't work for me either. If it helps you can always declare your routes like: 'firstlevel/secondlevel' => [ ['GET', 'endpoint', Example::class, 'test'], ], 'firstlevel/another-secondlevel' => [ ['GET', 'endpoint', Example::class, 'test'], ], I might add multiple nested groups in the future
  13. Hi @joshua, thanks for finding it useful 😉 Personally I mostly use the RestAPI Module to gather data from multiple sources for a single endpoint. For example a blogpost might have info about the post itself, but also might pull in additional data about the author which might live on a completely different page. However I can think of usecases like yours where bascially a dump of all the data might be useful. Unfortunately there is no built in functionality for this in the module. You could check out http://modules.processwire.com/modules/pages2-json/ which does a similar thing or the GraphQL Module (http://modules.processwire.com/modules/process-graph-ql/) also goes in this direction.
  14. Recently a user of this module had the problem that some multi-language fields weren't working correctly.kno After some investigation I discovered, that the hook this module uses (it's a "before ProcessPageView::execute") kicks in to early for the multi-language plugins to be ready. Does anyone knows of a hook, which can do something similar (basically take over the default routing of ProcessWire) while still have the other modules loaded? One alternative approach for this specific problem would be to not trigger the module via a hook but with an own template and page like the old RestApiProfile did. A couple of benefits would come for free aswell (these are my assumptions, not tested yet): ProCache should work without any workarounds Multi-Language works Websites in subdirectories (if working in ProcessWire in general) should work site profile export would work if the /api folder lives in /templates by default Any potential downsides I'm not seeing yet? Thoughts?
  15. @dragan Can you please check your php error log too?
×
×
  • Create New...