Search Options

Results per page
Sort
Preferred Languages
Advance

Results 61 - 70 of 1,772 for user5 (0.03 sec)

  1. docs/iam/opa.md

    1. ### 2. Create a sample OPA Policy
    2.  
    3. In another terminal, create a policy that allows root user all access and for all other users denies `PutObject`:
    4.  
    5. ```sh
    6. cat > example.rego <<EOF
    7. package httpapi.authz
    8.  
    9. import input
    10.  
    11. default allow = false
    12.  
    13. # Allow the root user to perform any action.
    14. allow {
    15. input.owner == true
    16. }
    17.  
    18. # All other users may do anything other than call PutObject
    19. allow {
    20. input.action != "s3:PutObject"
    Registered: Sun Nov 03 19:28:11 UTC 2024
    - Last Modified: Sun Jul 17 15:43:14 UTC 2022
    - 2.3K bytes
    - Viewed (0)
  2. tests/test_tutorial/test_security/test_tutorial005_an_py310.py

    1. response = client.get(
    2. "/users/me", headers={"Authorization": f"Bearer {access_token}"}
    3. )
    4. assert response.status_code == 400, response.text
    5. assert response.json() == {"detail": "Inactive user"}
    6.  
    7.  
    8. @needs_py310
    9. def test_read_items(client: TestClient):
    10. access_token = get_access_token(scope="me items", client=client)
    11. response = client.get(
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Mar 13 19:07:10 UTC 2024
    - 16.3K bytes
    - Viewed (0)
  3. tests/test_security_api_key_cookie.py

    1. from pydantic import BaseModel
    2.  
    3. app = FastAPI()
    4.  
    5. api_key = APIKeyCookie(name="key")
    6.  
    7.  
    8. class User(BaseModel):
    9. username: str
    10.  
    11.  
    12. def get_current_user(oauth_header: str = Security(api_key)):
    13. user = User(username=oauth_header)
    14. return user
    15.  
    16.  
    17. @app.get("/users/me")
    18. def read_current_user(current_user: User = Depends(get_current_user)):
    19. return current_user
    20.  
    21.  
    22. def test_security_api_key():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 1.9K bytes
    - Viewed (0)
  4. tests/test_security_api_key_cookie_description.py

    1. app = FastAPI()
    2.  
    3. api_key = APIKeyCookie(name="key", description="An API Cookie Key")
    4.  
    5.  
    6. class User(BaseModel):
    7. username: str
    8.  
    9.  
    10. def get_current_user(oauth_header: str = Security(api_key)):
    11. user = User(username=oauth_header)
    12. return user
    13.  
    14.  
    15. @app.get("/users/me")
    16. def read_current_user(current_user: User = Depends(get_current_user)):
    17. return current_user
    18.  
    19.  
    20. def test_security_api_key():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 2.1K bytes
    - Viewed (0)
  5. docs_src/security/tutorial004_an.py

    1. access_token = create_access_token(
    2. data={"sub": user.username}, expires_delta=access_token_expires
    3. )
    4. return Token(access_token=access_token, token_type="bearer")
    5.  
    6.  
    7. @app.get("/users/me/", response_model=User)
    8. async def read_users_me(
    9. current_user: Annotated[User, Depends(get_current_active_user)],
    10. ):
    11. return current_user
    12.  
    13.  
    14. @app.get("/users/me/items/")
    15. async def read_own_items(
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 4.2K bytes
    - Viewed (0)
  6. tests/scopes_test.go

    1. }
    2.  
    3. DB.Scopes(NameIn([]string{users[0].Name, users[2].Name})).Find(&users3)
    4. if len(users3) != 2 {
    5. t.Errorf("Should found two users's name in 1, 3, but got %v", len(users3))
    6. }
    7.  
    8. db := DB.Scopes(func(tx *gorm.DB) *gorm.DB {
    9. return tx.Table("custom_table")
    10. }).Session(&gorm.Session{})
    11.  
    12. db.AutoMigrate(&User{})
    13. if db.Find(&User{}).Statement.Table != "custom_table" {
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Fri Jan 12 08:42:21 UTC 2024
    - 3.3K bytes
    - Viewed (0)
  7. tests/test_security_openid_connect_optional.py

    1. oid = OpenIdConnect(openIdConnectUrl="/openid", auto_error=False)
    2.  
    3.  
    4. class User(BaseModel):
    5. username: str
    6.  
    7.  
    8. def get_current_user(oauth_header: Optional[str] = Security(oid)):
    9. if oauth_header is None:
    10. return None
    11. user = User(username=oauth_header)
    12. return user
    13.  
    14.  
    15. @app.get("/users/me")
    16. def read_current_user(current_user: Optional[User] = Depends(get_current_user)):
    17. if current_user is None:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 2.4K bytes
    - Viewed (0)
  8. tests/test_security_api_key_query_description.py

    1. app = FastAPI()
    2.  
    3. api_key = APIKeyQuery(name="key", description="API Key Query")
    4.  
    5.  
    6. class User(BaseModel):
    7. username: str
    8.  
    9.  
    10. def get_current_user(oauth_header: str = Security(api_key)):
    11. user = User(username=oauth_header)
    12. return user
    13.  
    14.  
    15. @app.get("/users/me")
    16. def read_current_user(current_user: User = Depends(get_current_user)):
    17. return current_user
    18.  
    19.  
    20. client = TestClient(app)
    21.  
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 2K bytes
    - Viewed (0)
  9. docs/en/docs/tutorial/security/simple-oauth2.md

    1. ```JSON
    2. {
    3. "detail": "Not authenticated"
    4. }
    5. ```
    6.  
    7. ### Inactive user
    8.  
    9. Now try with an inactive user, authenticate with:
    10.  
    11. User: `alice`
    12.  
    13. Password: `secret2`
    14.  
    15. And try to use the operation `GET` with the path `/users/me`.
    16.  
    17. You will get an "Inactive user" error, like:
    18.  
    19. ```JSON
    20. {
    21. "detail": "Inactive user"
    22. }
    23. ```
    24.  
    25. ## Recap
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 12.3K bytes
    - Viewed (0)
  10. tests/test_security_api_key_query.py

    1. from pydantic import BaseModel
    2.  
    3. app = FastAPI()
    4.  
    5. api_key = APIKeyQuery(name="key")
    6.  
    7.  
    8. class User(BaseModel):
    9. username: str
    10.  
    11.  
    12. def get_current_user(oauth_header: str = Security(api_key)):
    13. user = User(username=oauth_header)
    14. return user
    15.  
    16.  
    17. @app.get("/users/me")
    18. def read_current_user(current_user: User = Depends(get_current_user)):
    19. return current_user
    20.  
    21.  
    22. client = TestClient(app)
    23.  
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 1.8K bytes
    - Viewed (0)
Back to top