Skip to content

Commit

Permalink
fix: partial read permission on member table
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Dec 25, 2021
1 parent 572f8d9 commit 5102496
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pol/curd/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ async def get_by_valid_token(db: Database, access_token: str) -> User:

access = ChiiOauthAccessToken(**r)

r = await db.fetch_one(sa.get(ChiiMember, ChiiMember.uid == access.user_id))
r = await db.fetch_one(
sa.get(
ChiiMember.all_column(),
ChiiMember.uid == access.user_id,
)
)

if not r:
# 有access token又没有对应的user不太可能发生,如果发生的话打个 log 当作验证失败
Expand Down
8 changes: 8 additions & 0 deletions pol/db/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ class ChiiMember(Base):
)
sign = Column(VARCHAR(255), nullable=False)

@classmethod
def all_column(cls):
"""
This table contains only column with read permission,
don't `select *` on this table.
"""
return cls.__table__.columns


class ChiiOauthAccessToken(Base):
__tablename__ = "chii_oauth_access_tokens"
Expand Down

0 comments on commit 5102496

Please sign in to comment.