You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`Clone` the repository in your target client project
116
-
- Open the project solution and `build` the solution
117
-
- To use the `casbin-cpp` project in your client project add the path to the static library `casbin.lib` file to your client project properties under `VC++ Directories` > `Library Directories` and also add the path of `casbin` directory to your client project properties under `VC++ Directories` > `Include Directories`
118
-
- Add the static library file name `casbin.lib` to the properties under `Linker` > `Input` > `Additional Dependencies`
119
-
120
-
#### Unix
121
-
-`Clone` the repository in your target client project
122
-
- Change the current working directory to the `casbin-cpp` directory and build the library through following commands:
123
-
-***Make***
124
-
```shell
125
-
$ make
126
-
$ make library
114
+
### Build instructions for all platforms
115
+
116
+
(Assuming you have CMake v3.19 or later installed)
117
+
118
+
1. Clone/checkout to [`casbin/casbin-cpp:master`](https://github.com/EmperorYP7/casbin-cpp/tree/ctest-setup)
2. Add an enforcement hook into your code right before the access happens:
149
173
150
-
```c++
151
-
string sub = "alice"; // the user that wants to access a resource.
152
-
string obj = "data1"; // the resource that is going to be accessed.
153
-
string act = "read"; // the operation that the user performs on the resource.
174
+
```cpp
175
+
std::string sub = "alice"; // the user that wants to access a resource.
176
+
std::string obj = "data1"; // the resource that is going to be accessed.
177
+
std::string act = "read"; // the operation that the user performs on the resource.
154
178
155
-
if(e->Enforce({ sub, obj, act })) {
179
+
if(e.Enforce({ sub, obj, act })) {
156
180
// permit alice to read data1
157
181
} else {
158
182
// deny the request, show an error
@@ -161,10 +185,29 @@ Note: you can also initialize an enforcer with policy in DB instead of file, see
161
185
162
186
3. Besides the static policy file, Casbin also provides API for permission management at run-time. For example, You can get all the roles assigned to a user as below:
0 commit comments