Skip to content

Commit

Permalink
remove generate token from entities
Browse files Browse the repository at this point in the history
  • Loading branch information
rzlim08 committed Sep 22, 2023
1 parent c739386 commit a69c0e3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
2 changes: 1 addition & 1 deletion entities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To get a summary of other available `make` targets, run `make help`
docker compose exec entities bash
# Get a list of samples:
export PLATFORMICS_AUTH_TOKEN=$(./cli/gqlcli.py auth generate-token 111 --project 444:admin --expiration 3600)
export PLATFORMICS_AUTH_TOKEN=$(./platformics/cli/generate_token.py auth generate-token 111 --project 444:admin --expiration 3600)
./cli/gqlcli.py samples list
```

Expand Down
27 changes: 0 additions & 27 deletions entities/cli/gqlcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,5 @@ def auth() -> None:
pass


# TODO - this is just a temporary command to help us test the auth flow.
@auth.command("generate-token")
@click.argument("userid", required=True, type=int)
@click.option("--expiration", help="Duration of token in seconds", type=int)
@click.option(
"--project",
help="project_id:role associations to include in the header",
type=str,
default=["123:admin", "123:member", "456:member"],
multiple=True,
)
@click.pass_context
def generate_token(ctx: click.Context, userid: int, project: list[str], expiration: int) -> None:
settings = Settings.parse_obj({})
private_key = settings.JWK_PRIVATE_KEY

project_dict: dict[int, list[str]] = {}
for item in project:
project_id, role = item.split(":")
if int(project_id) not in project_dict:
project_dict[int(project_id)] = []
project_dict[int(project_id)].append(role)
project_schema = [ProjectRole(project_id=k, roles=v) for k, v in project_dict.items()]
token = create_token(private_key, userid, project_schema, expiration)
print(token)


if __name__ == "__main__":
cli()

0 comments on commit a69c0e3

Please sign in to comment.