Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum
0

it was a very stupid mistake

i have this interanl concept of "role templates" which are made up of a few object / action pairs - and i decorate them with user context informaiton

but i was not copying the template array - so after the first user registered - subequent users were getting more perms than my polciy specified

RIP

lol

+       dest := make([][]string, len(policy))
        for i := 0; i < len(policy); i++ {
-               policy[i] = decoratePolicy(policy[i], user, guild)
+               dest[i] = decoratePolicy(policy[i], user, guild)
        }
-       return policy
+       return dest
 }

that correclty does what i meant to do

took me a while to figure it out 😛

0

I did figure it out and it was all on my eend - wooo woooo - casbin has been awesome to build against.

0

a bit more infomration - it seems that i may have a bug on my end and pretty much what is happening is when im generating policies to be saved - some infomration from the previous request is haniging around and curropting my policy string - ill keep digging !

0

I think I am missing someting about how casbin caches policies internally - and then in my implementation doing something wrong.

0

Hey all - I have a maybe werid question but am running into an issue and am having a hard time figuring out what is going on.

I can paste some code to show folks but from a high level what I am observing is as follows:

I have a 3 "slot" policy - where v0 is a uuid, v1 is a "context" and v2 is an action "read / write / delete" etc

During my registration flow - the policy gets updated twice. ( I call AddPolicies() and SavePolicy() each time )

Once when the user initially creates an oauth2 session - and then again when they make a selection about an org to join.

The issue I am running into is the following:

Often during registration something funky happens and a policy gets saved with 4 fields rather than 3 - this causes casbin to blow up as it doesnt know what to do with a 4 field policy with my configuration. This then currupts the internal cache casbin seems to keep.

A very hacky fix - is to remove the policies in my Postgres DB that have the extra fields - then restart the server.

I am trying to debug my code and figure out whats going on - but wanted to describe the symptoms of the issue I am experienceing to see if it sounds familiar to anyone.