Skip to content

Commit

Permalink
merge conflict in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Taniya-Das committed Oct 30, 2023
2 parents 4eade30 + e60ad31 commit 5413bc1
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ following figure:

## Prerequisites
- Linux/MacOS/Windows (should all work)
- [Docker](https://docs.docker.com/get-docker/)
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/) version 2.21.0 or higher

For development:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
# This minimal example is for back-end services that want to authenticate as a server.
# Use this example if you want to upload data in the name of the service, not in the name
# of a user.
# Another option for back-end services would be to let users login / to impersonate users.



# Ask admin of https://aiod-dev.i3a.es/aiod-auth keycloak, e.g. Rafael, for a secret
CLIENT_ID="PUT CLIENT ID HERE"
SECRET="PUT THE SECRET HERE"


if [ "${CLIENT_ID}" = "PUT CLIENT ID HERE" ]; then
echo "Error: put the correct client id in the script"
exit 1
fi
if [ "${SECRET}" = "PUT THE SECRET HERE" ]; then
echo "Error: put the correct secret in the script"
exit 1
fi


TOKEN_DICT=$(curl \
-d "client_id=${CLIENT_ID}" \
-d "client_secret=${SECRET}" \
-d "grant_type=client_credentials" \
-d "scope=openid profile roles" \
"https://aiod-dev.i3a.es/aiod-auth/realms/aiod/protocol/openid-connect/token" \
| python3 -m json.tool
)

TOKEN=$(
echo $TOKEN_DICT \
| jq .access_token \
| tr -d '"'
)

echo "TOKEN: "
echo $TOKEN
echo "(should not be null)"

RESULT=$(
curl -X 'GET' \
-H "Accept: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
https://aiod-dev.i3a.es/authorization_test
)


echo "Result of auth test:"
echo $RESULT
77 changes: 77 additions & 0 deletions examples/upload/example_upload_dataset_with_service_account.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
# This minimal example uses service authentication.



# Ask admin of https://aiod-dev.i3a.es/aiod-auth keycloak, e.g. Rafael, for a secret
CLIENT_ID="PUT CLIENT ID HERE"
SECRET="PUT THE SECRET HERE"


if [ "${CLIENT_ID}" = "PUT CLIENT ID HERE" ]; then
echo "Error: put the correct client id in the script"
exit 1
fi
if [ "${SECRET}" = "PUT THE SECRET HERE" ]; then
echo "Error: put the correct secret in the script"
exit 1
fi


TOKEN_DICT=$(curl \
-d "client_id=${CLIENT_ID}" \
-d "client_secret=${SECRET}" \
-d "grant_type=client_credentials" \
-d "scope=openid profile roles" \
"https://aiod-dev.i3a.es/aiod-auth/realms/aiod/protocol/openid-connect/token" \
| python3 -m json.tool
)

TOKEN=$(
echo $TOKEN_DICT \
| jq .access_token \
| tr -d '"'
)


echo "POSTING a new dataset..."

# Only a name is added for this dataset. See https://aiod-dev.i3a.es/docs#/ for all possible fields.
RESULT=$(
curl -X 'POST' \
-H "Accept: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"name": "test"}' \
https://aiod-dev.i3a.es/datasets/v1
)



IDENTIFIER=$(
echo $RESULT \
| jq .identifier \
| tr -d '"'
)
echo "Identifier of the new dataset (should not be null):"
echo $IDENTIFIER


echo "Trying to retrieve the just posted dataset of the platform..."
NEW_DATASET=$(
curl -X 'GET' \
-H "Accept: application/json" \
https://aiod-dev.i3a.es/datasets/v1/${IDENTIFIER}
)
echo "New dataset as found on the platform:"
echo $NEW_DATASET | jq .


echo "Deleting the dataset again, because it was just a test..."
DELETED=$(
curl -X 'DELETE' \
-H "Authorization: Bearer ${TOKEN}" \
-H "Accept: application/json" \
https://aiod-dev.i3a.es/datasets/v1/${IDENTIFIER}
)
echo "Done."
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "ai4eu_server_demo"
description = "A containerized demo application for AI on demand (previously AI4EU) "
version = "0.4.20230627"
version = "1.0.20230911"
requires-python = ">=3.11"
authors = [

Expand All @@ -13,10 +13,10 @@ authors = [
{name = "Taniya Das", email = "[email protected]"}
]
dependencies = [
"urllib3== 2.0.4",
"bibtexparser==1.4.0",
"datasets==2.14.4",
"fastapi==0.103.1",
"urllib3== 2.0.7",
"bibtexparser==1.4.1",
"datasets==2.14.5",
"fastapi==0.104.0",
"uvicorn==0.23.2",
"requests==2.31.0",
"mysqlclient==2.2.0",
Expand All @@ -26,7 +26,7 @@ dependencies = [
"pydantic_schemaorg==1.0.6",
"python-dateutil==2.8.2",
"sqlmodel==0.0.8",
"httpx==0.24.1",
"httpx==0.25.0",
"sickle==0.7.0",
"xmltodict==0.13.0",
"python-multipart==0.0.6",
Expand All @@ -40,7 +40,7 @@ dev = [
"pytest==7.4.2",
"pytest-dotenv==0.5.2",
"pytest-xdist==3.3.1",
"pre-commit==3.4.0",
"pre-commit==3.5.0",
"responses==0.23.3",
"starlette==0.27.0"
]
Expand Down

0 comments on commit 5413bc1

Please sign in to comment.