Skip to content

Commit

Permalink
Merge pull request #111 from whdalsrnt/master
Browse files Browse the repository at this point in the history
Apply for Identity v2
  • Loading branch information
whdalsrnt authored Dec 8, 2023
2 parents 79f9684 + 280a3ee commit 1dce63b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
8 changes: 0 additions & 8 deletions deploy/helm/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,3 @@ GLOBAL:
- mobile
Token.issue:
- credentials

HANDLERS:
authentication:
- backend: spaceone.core.handler.authentication_handler.AuthenticationGRPCHandler
uri: grpc://identity:50051/v1/Domain/get_public_key
authorization:
- backend: spaceone.core.handler.authorization_handler.AuthorizationGRPCHandler
uri: grpc://identity:50051/v1/Authorization/verify
1 change: 1 addition & 0 deletions src/spaceone/identity/conf/global_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"SpaceConnector": {
"backend": "spaceone.core.connector.space_connector.SpaceConnector",
"endpoints": {
"identity": "grpc://localhost:50051",
"plugin": "grpc://plugin:50051",
"secret": "grpc://secret:50051",
"repository": "grpc://repository:50051",
Expand Down
2 changes: 0 additions & 2 deletions src/spaceone/identity/model/api_key/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ class APIKeySearchQueryRequest(BaseModel):
query: Union[dict, None] = None
api_key_id: Union[str, None] = None
name: Union[str, None] = None
owner_type: str = "USER"
user_id: Union[str, None] = None
state: Union[str, None] = None
domain_id: str


class APIKeyStatQueryRequest(BaseModel):
query: dict
owner_type: str = "USER"
domain_id: str
user_id: Union[str, None] = None
5 changes: 2 additions & 3 deletions src/spaceone/identity/service/api_key_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def list(self, params: APIKeySearchQueryRequest) -> Union[APIKeysResponse, dict]
'query': 'dict',
'api_key_id': 'str',
'name': 'str',
'owner_type': 'str',
'user_id': 'str',
'state': 'str',
'domain_id': 'str' # required
Expand All @@ -208,7 +207,6 @@ def stat(self, params: APIKeyStatQueryRequest) -> dict:
Args:
params (dict): {
'query': 'dict', # required
'owner_type': 'str',
'domain_id': 'str', # required
'user_id': 'str', # from meta
}
Expand All @@ -219,6 +217,8 @@ def stat(self, params: APIKeyStatQueryRequest) -> dict:
}
"""
query = params.query or {}
query = self._append_owner_type_filter(query)

return self.api_key_mgr.stat_api_keys(query)

@staticmethod
Expand All @@ -236,7 +236,6 @@ def _get_expired_at(expired_at: str) -> str:
@staticmethod
def _check_expired_at(expired_at: str) -> None:
one_year_later = datetime.now() + timedelta(days=365)
print(one_year_later)

if one_year_later.strftime("%Y-%m-%d %H:%M:%S") < expired_at:
raise ERROR_API_KEY_EXPIRED_LIMIT(expired_at=expired_at)
12 changes: 6 additions & 6 deletions src/spaceone/identity/service/domain_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from spaceone.core.service import *
from spaceone.core.service.utils import *
from spaceone.core import utils

from spaceone.identity.manager.external_auth_manager import ExternalAuthManager
from spaceone.identity.manager.domain_manager import DomainManager
Expand All @@ -17,11 +18,10 @@
_LOGGER = logging.getLogger(__name__)


# @authentication_handler
# @authorization_handler
# @request_mutation_handler
# @response_mutation_handler
# @event_handler
@authentication_handler
@authorization_handler
@mutation_handler
@event_handler
class DomainService(BaseService):

service = "identity"
Expand Down Expand Up @@ -201,7 +201,7 @@ def get_public_key(
"""

pub_jwk = self.domain_secret_mgr.get_domain_public_key(params.domain_id)
return DomainSecretResponse(public_key=str(pub_jwk), domain_id=params.domain_id)
return DomainSecretResponse(public_key=utils.dump_json(pub_jwk), domain_id=params.domain_id)

@transaction(scope='system_admin:read')
@append_query_filter(["domain_id", "name", "state"])
Expand Down

0 comments on commit 1dce63b

Please sign in to comment.