• Blackmist@feddit.uk
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 hours ago

    I did this just to reduce network latency. It’s not for public use, and tbh, I don’t think you can even get at it from outside the VPN.

  • julianwgs@discuss.tchncs.de
    link
    fedilink
    arrow-up
    9
    ·
    6 hours ago

    Why not?

    We did that for a Plotly dashboard in Python. We copied the database into a read-only in-memory sqlite database (it is quite small, only a couple thousand entries) to prevent any damages outside the dashboard. The data only gets updated every couple of days. You could skip this step. Then with sqlite you can restrict what action a query can use (SELECT, JSON, etc.) and you can restrict the instructions per query to prevent denial of service. It works like a charm and is much simpler than providing a REST API. Also the user might already know SQL.

    I am actually planning something similar for a task management web app I am building at the moment (additionally to providing a REST API). No need to learn another query language like in Jira.

    • shoo@lemmy.world
      link
      fedilink
      arrow-up
      14
      ·
      5 hours ago

      Couple of reasons of varying importance:

      • Security. Even when you limit operations or table access it’s very easy to mess something up. Some new employee starts storing sensitive data in the wrong place or a db admin accidentally turns off the wrong permissions, etc…
      • It’s secretly more overengineered than a standard api despite looking simpler. If your app needs extremely robust query capabilities then you probably have a use case for an entire analytics stack and could use an open source option. Otherwise your users probably just need basic search, filtering, sorting, etc…
      • Ungodly, Flex Tape tier tight coupling. Part of the purpose of an api is to abstract away implementation details and present a stable contract. Now if you want to migrate/upgrade the database or add a new data source, everyone has to know about it and it’s potentially a major breaking change.
      • Familiarity. If someone else steps in to maintain it it’s much easier to get up to speed with a more standard stack. You don’t need a seven layer salad of enterprise abstraction bullshit, but it’s useful to see a familiar separation of auth, queries, security, etc…
      • Having the option to do business logic outside of the database can save countless headaches. Instead of inventing views or kludging sprocs to do some standard transformation, you can pull in a mature library. Some things, such as scrubbing PII, are probably damn near impossible without a higher tier layer to work in.
      • Client support. Your browser/device probably has a few billion options for consuming a REST/HATEOAS/graphql/whatever api. I doubt there’s many direct sql options with wide support.

      I probably wouldn’t do it outside of a tiny solo project. There are plenty of frameworks which do similar things (such as db driven apis) without compromising on flexibility, security or features.

  • Buckshot@programming.dev
    link
    fedilink
    arrow-up
    12
    ·
    10 hours ago

    I got dumped with fixing some bugs in a project written by a contractor who had literally done this but with extra steps.

    Backend was sql server and c#/asp.

    There was an api endpoint that took json, used xslt to transform to xml. Then called the stored procedure specified in request passing the xml as a parameter.

    The stored procedure then queried the xml for parameters, executed the query, and returned results as xml.

    Another xslt transformed that to json and returned to the client.

    It was impressive how little c# there was.

    Despite holding all the business logic, the sql was not in source control.

    • passepartout@feddit.org
      link
      fedilink
      arrow-up
      112
      ·
      1 day ago

      My friend who helped me research the OAuth vulnerabilities was let go for “security concerns from corporate”

      Good old shooting the messenger.

      • ZoteTheMighty@lemmy.zip
        link
        fedilink
        arrow-up
        15
        ·
        1 day ago

        I mean, they were an employee who was exploring security vulnerabilities with a non-employee who has a blog. I would have fired them too.

        • passepartout@feddit.org
          link
          fedilink
          arrow-up
          14
          ·
          1 day ago

          It is indeed a very risky move without a lot to gain for him personally. But I could guess McDonald’s would have forced him to ignore it and shut up about it if he disclosed this to the higher ups himself, in which case I would have gladly left myself instead.

  • x00z@lemmy.world
    link
    fedilink
    English
    arrow-up
    28
    ·
    24 hours ago

    This is still over engineered. Just connect directly to the database from the client instead of having an API endpoint.

  • kibiz0r@midwest.social
    link
    fedilink
    English
    arrow-up
    10
    ·
    23 hours ago

    Does ReST mean anything anymore? It was originally a set of principles guiding the development of the HTTP 1.1 spec. Then it meant mapping CRUD to HTTP verbs so application-agnostic load balancers could work right. And now I guess it’s just HTTP+JSON?

  • troed@fedia.io
    link
    fedilink
    arrow-up
    16
    ·
    1 day ago

    Great idea. How can we submit this to all AI scrapers?

    /cybersec red teamer

  • TrickDacy@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    23 hours ago

    I wish I could go back to rest apis. My company is all in on graphql and it fucking sucks so much ass.