Skip to content

fix: add map support to request struct - #8

Merged
hsluoyz merged 2 commits into
apache:masterfrom
x-qdo:add-map-support
Jan 11, 2022
Merged

fix: add map support to request struct#8
hsluoyz merged 2 commits into
apache:masterfrom
x-qdo:add-map-support

Conversation

@Hawatz

@Hawatz Hawatz commented Jan 6, 2022

Copy link
Copy Markdown
Contributor

Here we have a check for number and binary values, but what if we have a need to use maps in functions inside matcher expression

Convert maps to strings before passing it to request and back inside a function looks a bit tricky
Or maybe you have some reason to filter maps from request values?

@casbin-bot

Copy link
Copy Markdown

@tangyang9464 @closetool @sagilio please review

@CLAassistant

CLAassistant commented Jan 6, 2022

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hsluoyz

hsluoyz commented Jan 7, 2022

Copy link
Copy Markdown
Member

@Hawatz plz fix:

image

Hawatz added 2 commits January 7, 2022 17:17
* add is_map() check to request validation to be able to use maps in request
* update the link to point to the current repository, because the previous one is outdated
@Hawatz Hawatz changed the title Add map support to request struct fix: add map support to request struct Jan 7, 2022
@Hawatz

Hawatz commented Jan 7, 2022

Copy link
Copy Markdown
Contributor Author

@hsluoyz
Done

@hsluoyz
hsluoyz requested review from ngoclinhng and removed request for kilosonc, sagilio and tangyang9464 January 7, 2022 15:49
@hsluoyz

hsluoyz commented Jan 7, 2022

Copy link
Copy Markdown
Member

@ngoclinhng plz review

@ngoclinhng ngoclinhng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please follow the original coding-style (indentation: two white spaces, max-length: 80, etc...)
  • Can you give us a (real world) example where you need to use a map inside a request?

@Hawatz

Hawatz commented Jan 10, 2022

Copy link
Copy Markdown
Contributor Author

Can you give us a (real world) example where you need to use a map inside a request?

[matchers]
m = ... && custom_function(r, p)
  1. Inside custom_function we want to evaluate p.rule which can be r.user.id == p.user_id
    In that case, we can pass user_id directly to rule, but user_id is not the only field we want to check, especially when the user struct is nested
  2. We have a policy with the check that affects two maps from request, but we want this check to be stored in policy, not in the actual codebase

@kuzaxak

kuzaxak commented Jan 10, 2022

Copy link
Copy Markdown

Can you give us a (real world) example where you need to use a map inside a request?

[matchers]
m = ... && custom_function(r, p)
  1. Inside custom_function we want to evaluate p.rule which can be r.user.id == p.user_id
    In that case, we can pass user_id directly to rule, but user_id is not the only field we want to check, especially when the user struct is nested
  2. We have a policy with the check that affects two maps from request, but we want this check to be stored in policy, not in the actual codebase

We want to use Eval rule inside a policy against full obgect in request. It is available in original casbin, here is example

Eval rull will have access to the user record and resources object to run ABAC model.

@ngoclinhng

Copy link
Copy Markdown
Contributor

@hsluoyz you can merge these commits into master.

@hsluoyz
hsluoyz merged commit 5b0e701 into apache:master Jan 11, 2022
@kuzaxak
kuzaxak deleted the add-map-support branch January 11, 2022 16:12
github-actions Bot pushed a commit that referenced this pull request Oct 12, 2025
# 1.0.0 (2025-10-12)

### Bug Fixes

* add map support to request struct ([#8](#8)) ([5b0e701](5b0e701))
* add_policy at enforcer server hasn't handled a case where new_enforce comes. ([#6](#6)) ([a7478b8](a7478b8))
* enforcer_server ([#21](#21)) ([85efaa4](85efaa4))
* g3 matcher function + tests ([#13](#13)) ([d26a73c](d26a73c))

### Features

* add CI/CD automation with GitHub Actions and semantic-release ([#26](#26)) ([f775b8f](f775b8f))
* add EnforcerServer.reset_configuration/1 method ([#15](#15)) ([0e530da](0e530da))
* added persist adapters and ability to alter policies and mappings ([#19](#19)) ([d55e97a](d55e97a))
* keyMatch2 implementation ([#11](#11)) ([c68edd2](c68edd2))
* RBAC domain model ([#10](#10)) ([daafa79](daafa79))
* upgrade required elixir version to 1.13 ([#17](#17)) ([e828e3f](e828e3f))

### BREAKING CHANGES

* Drop support for elixir < 1.13

* chore: mix format

* chore: Add .tool-versions
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants