Comments (1)
In vj4, there are two things called permission and privilege. Permission is per-domain and privilege is per-system (for the entire site).
In code we usually assert permission and privilege requirements by applying decorators on view handlers. For example, in vj4/view/discussion.py:50
:
@app.route('/discuss/{node_or_pid}/create', 'discussion_create')
class DiscussionCreateView(base.View):
@base.require_priv(builtin.PRIV_USER_PROFILE)
@base.require_perm(builtin.PERM_CREATE_DISCUSSION)
@base.route_argument
@base.sanitize
async def get(self, *, node_or_pid: document.convert_doc_id):
vnode = await discussion.get_vnode(self.domain_id, node_or_pid)
The discussion_create
view requires PRIV_USER_PROFILE
privilege and PERM_CREATE_DISCUSSION
permission.
Privileges are directly stored in the user collection, where most user's privilege should be 4
, which is PRIV_USER_PROFILE
, which means the user has access to its user profile. Guest user (hardcoded in vj4/model/builtin.py
) doesn't have PRIV_USER_PROFILE
, but it has PRIV_REGISTER_USER
.
My UID is -4
, and I can run the following command in MongoDB shell to see my privilege.
> db.user.findOne({_id: -4}, {priv: 1})
{ "_id" : -4, "priv" : 4 }
Say you want to play with the judge playground, which is an interactive web page where you can behave like a judger. The judge playground requires PRIV_READ_RECORD_CODE
and builtin.PRIV_WRITE_RECORD
which normal users don't have. Since
PRIV_USER_PROFILE (4) + PRIV_READ_RECORD_CODE (16) + PRIV_WRITE_RECORD (64) = 84
You can run the following command in MongoDB shell to change the privilege.
> db.user.updateOne({_id: -4}, {$set: {priv: NumberInt(84)}})
{ "acknowledged" : true, "matchedCount" : 1, "modifiedCount" : 1 }
And then you can verify by:
> db.user.findOne({_id: -4}, {priv: 1})
{ "_id" : -4, "priv" : 84 }
Permission is another thing, which is not fully implemented and not useful for now.
from vj4.
Related Issues (20)
- sockjs 0.10 (>0.9) does not work.
- Failed to call 'afterLoading' of record_detail HOT 3
- Something goes wrong when access it HOT 5
- Help! How to add a problem from command line HOT 1
- Allow author of a training to view the list of trainee, and their report or progress. HOT 1
- support site map
- typo
- ? HOT 4
- UI width breakpoints HOT 1
- Deadlink to beian.miit.gov.cn
- Support domain data import/export
- Archived Discussions
- Human-readable file name for exported student code HOT 1
- mmdb download issue HOT 4
- When some unaccpetable cookie passed, server responses 500
- About special characters in tag names | 关于题目标签名中的特殊字符
- deployment on linode HOT 3
- python3.8 AttributeError: module 'platform' has no attribute 'linux_distribution' HOT 1
- css problem on firefox 35.0 (NOI Linux version): page content invisible
- Broken Pipe HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vj4.