Skip to content

Commit

Permalink
inital test
Browse files Browse the repository at this point in the history
  • Loading branch information
daveads committed Oct 20, 2024
1 parent 59b2f89 commit b84bd88
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ def create(
cedar_auth_token=store_token,
auth_type=auth_type,
)

#Openfga
elif PolicyStoreTypes.OPENFGA == store_type:
from opal_client.policy_store.openfga_client import OpenFGAClient

res = OpenFGAClient(
openfga_server_url=url,
openfga_auth_token=store_token,
auth_type=auth_type,
store_id=opal_client_config.OPENFGA_STORE_ID,
)

# MOCK
elif PolicyStoreTypes.MOCK == store_type:
from opal_client.policy_store.mock_policy_store_client import (
Expand Down
14 changes: 4 additions & 10 deletions packages/opal-client/opal_client/policy_store/schemas.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,42 @@
from enum import Enum
from typing import Optional

from pydantic import BaseModel, Field, validator


class PolicyStoreTypes(Enum):
OPA = "OPA"
CEDAR = "CEDAR"
OPENFGA = "OPENFGA"
MOCK = "MOCK"


class PolicyStoreAuth(Enum):
NONE = "none"
TOKEN = "token"
OAUTH = "oauth"
TLS = "tls"


class PolicyStoreDetails(BaseModel):
"""
represents a policy store endpoint - contains the policy store's:
Represents a policy store endpoint - contains the policy store's:
- location (url)
- type
- credentials
"""

type: PolicyStoreTypes = Field(
PolicyStoreTypes.OPA,
description="the type of policy store, currently only OPA is officially supported",
)
url: str = Field(
...,
description="the url that OPA can be found in. if localhost is the host - "
"it means OPA is on the same hostname as OPAL client.",
"it means OPA is on the same hostname as OPAL client.",
)
token: Optional[str] = Field(
None, description="optional access token required by the policy store"
)

auth_type: PolicyStoreAuth = Field(
PolicyStoreAuth.NONE,
description="the type of authentication is supported for the policy store.",
)

oauth_client_id: Optional[str] = Field(
None, description="optional OAuth client id required by the policy store"
)
Expand All @@ -63,4 +57,4 @@ def force_enum(cls, v):

class Config:
use_enum_values = True
allow_population_by_field_name = True
allow_population_by_field_name = True
1 change: 1 addition & 0 deletions packages/opal-client/requires.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ psutil>=5.9.1,<6
tenacity>=8.0.1,<9
dpath>=2.1.5,<3
jsonpatch>=1.33,<2
openfga-sdk==0.7.2

0 comments on commit b84bd88

Please sign in to comment.