Giter Club home page Giter Club logo

fake_firebase_security_rules's People

Contributors

atn832 avatar cedvdb avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

cedvdb

fake_firebase_security_rules's Issues

Support resource/request.resource

Supporting resource and request.resource can be done in one of two ways.

The easy, less robust way, is for fake_cloud_firestore to populate the resource and request.resource objects "manually" into context. https://github.com/atn832/fake_cloud_firestore/blob/be3e548e20fda9af263134dc813c4a8842c316db/lib/src/fake_cloud_firestore_instance.dart#L151

The other, more robust way is when calling fake_firebase_security_rules's isAllowed, fake_firebase_security_rules should be able to ask Resource information from the caller (fake_cloud_firestore or firebase_storage_mocks) and populate that into the context in the right places (both in resource and request.resource).

Maybe it could be implemented like this: implement some ResourceProvider interface

class ResourceProvider {
  // based on https://firebase.google.com/docs/reference/rules/rules.firestore.Resource.
  Resource get(String path);
}

Add a resourceProvider parameter to isAllowed or to the FakeFirebaseSecurityRules constructor.

bool isAllowed(String path, Method method,
{Map<String, dynamic> variables = const {}}) {

FakeFirebaseSecurityRules(String securityRules, {Logger? logger})

Then in

/// Evaluates whether an operation is allowed or not. `path` is the full path
/// from root without a starting '/'.
bool isAllowed(String path, Method method,
{Map<String, dynamic> variables = const {}}) {
or
// Full match.
for (final allowStatement in allowStatements) {
final program = allowStatement.item2;
final finalVariables = {

fake_firebase_security_rules can query the Resource data and put it both in context and context.request.

The reason why the second approach is more robust is that neitherfake_cloud_firestore nor firebase_storage_mocks have to know about where that resource is put.

Anyone is free to implement a PR with unit tests and I'll gladly review it.

Unexpected token 'null' on web

Screenshot 2023-02-21 at 14 27 24

Because fake_cloud_firestore is using this package, it will although not work on web atm.

This might be a naming problem for one of the files and might be happening while compiling dart code into JS code.

Reproduce:

  • Create new flutter project (v. 3.7.3 stable)
  • Add fake_firebase_security_rules: to dependencies
  • Call FakeFirebaseSecurityRules(''); somewhere, e.g. build method.

FYI: This error will only occure in debug mode, not in profile or release.

Resource and Function feature

Are there any ETAs on the resource/request.resource and custom function features?
When can we expect these features?

Is there a way how we could contribute to that?

And also, if a rules file has missing features in it like these, will other parts of the rules file still work which do not rely on such features?

Support functions

In order to implement this, one will have to first enable cel-dart to support Overloads. Then fake_firebase_security_rules should implement some functions, and instantiate Programs with a custom Environment that provides those functions.

See atn832/cel-dart#1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.