Results of 1 - 4 of about 4 for UserInDB (0.008 sec.)
- Simple OAuth2 with Password and Bearer 12408
- Simple OAuth2 with Password and Bearer Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Now let's build from the previous chapter and add the missing parts to have
...( BaseModel ): username : str email : str | None = None full_name : str | None = None disabled : bool | None = None class UserInDB ( User ): hashed_password : str def get_user ( db , username : str ): if username in db : user_dict = db [ username ] retu...rn UserInDB ( ** user_dict ) def fake_decode_token ( token ): # This doesn't provide any security at all # Check the next version user...username ) if not user_dict : raise HTTPException ( status_code = 400 , detail = "Incorrect username or password" ) user = UserInDB ( ** user_dict ) hashed_password = fake_hash_password ( form_data . password ) if not hashed_password == user . hashed_pas... - https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
- OAuth2 scopes 8580
- OAuth2 scopes Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use OAuth2 scopes directly with FastAPI , they are integrated to work seamlessly. This would
...( BaseModel ): username : str email : str | None = None full_name : str | None = None disabled : bool | None = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme =...d_context . hash ( password ) def get_user ( db , username : str ): if username in db : user_dict = db [ username ] return UserInDB ( ** user_dict ) def authenticate_user ( fake_db , username : str , password : str ): user = get_user ( fake_db , username...email : Union [ str , None ] = None full_name : Union [ str , None ] = None disabled : Union [ bool , None ] = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme =... - https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
- モデル - より詳しく 8044
- モデル - より詳しく 先ほどの例に続き、複数の関連モデルを持つことが一般的です。 これはユーザーモデルの場合は特にそうです。なぜなら: 入力モデル にはパスワードが必要です。 出力モデル はパスワードをもつべきではありません。 データベースモデル は
..., None ] = None class UserOut ( BaseModel ): username : str email : EmailStr full_name : Union [ str , None ] = None class UserInDB ( BaseModel ): username : str hashed_password : str email : EmailStr full_name : Union [ str , None ] = None def fake_pass...ssword def fake_save_user ( user_in : UserIn ): hashed_password = fake_password_hasher ( user_in . password ) user_in_db = UserInDB ( ** user_in . dict (), hashed_password = hashed_password ) print ( "User saved! ..not really" ) return user_in_db @app ...._name : str | None = None class UserOut ( BaseModel ): username : str email : EmailStr full_name : str | None = None class UserInDB ( BaseModel ): username : str hashed_password : str email : EmailStr full_name : str | None = None def fake_password_hashe... - https://man.mtool.work/fastapi/0.115/tutorial/extra-models/
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 7914
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ
...email : Union [ str , None ] = None full_name : Union [ str , None ] = None disabled : Union [ bool , None ] = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme =...d_context . hash ( password ) def get_user ( db , username : str ): if username in db : user_dict = db [ username ] return UserInDB ( ** user_dict ) def authenticate_user ( fake_db , username : str , password : str ): user = get_user ( fake_db , username...( BaseModel ): username : str email : str | None = None full_name : str | None = None disabled : bool | None = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme =... - https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
PREV
1
NEXT