Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #27

Merged
merged 49 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
4e6b9eb
Fix develop dockerfile
daniel-pimenta-DME Jul 5, 2023
918d4c6
Change keycloak urls
daniel-pimenta-DME Jul 5, 2023
ba4b8b6
Fix develop workflow tag
daniel-pimenta-DME Jul 5, 2023
5796045
Fix production workflow
daniel-pimenta-DME Jul 5, 2023
9f4d9c2
Change log message
daniel-pimenta-DME Jul 5, 2023
45704b4
Change config
daniel-pimenta-DME Jul 5, 2023
8fefb80
Add health check
daniel-pimenta-DME Jul 5, 2023
e2b6f3f
Fix health check
daniel-pimenta-DME Jul 5, 2023
e9b702d
Add ready health endpoint
daniel-pimenta-DME Jul 5, 2023
7ad7d20
Fix issue
daniel-pimenta-DME Jul 5, 2023
94c2d7e
Change workflow filenames
daniel-pimenta-DME Jul 5, 2023
4667b27
Eoepca 910 um keycloak develop an identity api based on keycloak api …
flaviorosadme Jul 25, 2023
e8f2581
Update README
daniel-pimenta-DME Aug 21, 2023
7726408
Merge branch 'develop' of https://github.com/EOEPCA/um-identity-api i…
daniel-pimenta-DME Aug 21, 2023
6743f64
Update config
daniel-pimenta-DME Sep 26, 2023
f9c6a84
Update config
daniel-pimenta-DME Sep 26, 2023
8468ce0
Update config
daniel-pimenta-DME Sep 26, 2023
c170db2
Api testing (#18)
flaviorosadme Oct 9, 2023
cf2d35a
Update ci
daniel-pimenta-DME Oct 10, 2023
5eecb1e
Update ci
daniel-pimenta-DME Oct 10, 2023
b6a0828
Release v1.0.0
daniel-pimenta-DME Oct 15, 2023
197b1c0
Fix ci
daniel-pimenta-DME Oct 15, 2023
85b8f27
Fix requirements
daniel-pimenta-DME Oct 15, 2023
5aace57
Fix ci
daniel-pimenta-DME Oct 15, 2023
f0ac15a
Merge branch 'master' into develop
daniel-pimenta-DME Oct 15, 2023
e5559d5
Upgrade flask version
daniel-pimenta-DME Oct 15, 2023
b86284c
Merge branch 'develop' of https://github.com/EOEPCA/um-identity-api i…
daniel-pimenta-DME Oct 15, 2023
df2ec57
Update requirements
daniel-pimenta-DME Oct 15, 2023
de3ee6c
Merge branch 'master' into develop
daniel-pimenta-DME Oct 15, 2023
c19db10
feat: added error handling (#23)
flaviorosadme Oct 16, 2023
7fda506
feat: added validator of register and protect resource enpoint to test
flaviorosadme Oct 18, 2023
9d51ae6
Merge branch 'develop' of https://github.com/EOEPCA/um-identity-api i…
flaviorosadme Oct 18, 2023
ffe7a1d
feat: register and protect resources endpoint working
flaviorosadme Oct 19, 2023
a8c62a6
feat: added delete resources, policies and permissions
flaviorosadme Oct 20, 2023
734244e
Update ci
daniel-pimenta-DME Oct 23, 2023
2de9bfd
Merge branch 'develop' of https://github.com/EOEPCA/um-identity-api i…
daniel-pimenta-DME Oct 23, 2023
acc4fed
Update ci
daniel-pimenta-DME Oct 23, 2023
004b489
Fix ci
daniel-pimenta-DME Oct 24, 2023
9d8c034
Add options method to endpoints
daniel-pimenta-DME Oct 29, 2023
e5cdcae
Merge branch 'master' into develop
daniel-pimenta-DME Oct 29, 2023
82a5a5f
feat: added endpoint to create client, add resources and protect them…
flaviorosadme Nov 8, 2023
9ad30a0
Merge branch 'develop' of https://github.com/EOEPCA/um-identity-api i…
flaviorosadme Nov 8, 2023
deb3afe
Revert "Add options method to endpoints"
flaviorosadme Nov 8, 2023
63089e0
Merge remote-tracking branch 'origin/master' into develop
flaviorosadme Nov 8, 2023
b3514a6
fea: commit fixes
flaviorosadme Nov 8, 2023
2d6426c
feat: more fixes, some endpoint were dounbled
flaviorosadme Nov 8, 2023
8d77748
fix: last fix
flaviorosadme Nov 8, 2023
7d57858
Update ci
daniel-pimenta-DME Nov 9, 2023
928816d
Merge branch 'develop' of https://github.com/EOEPCA/um-identity-api i…
daniel-pimenta-DME Nov 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/docker-publish-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v1.13.1'
cosign-release: 'v2.1.1'

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
Expand Down Expand Up @@ -78,7 +78,6 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
Expand All @@ -87,10 +86,12 @@ jobs:
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

- name: Log into registry ${{ env.DOCKER_REGISTRY }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/docker-publish-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v1.13.1'
cosign-release: 'v2.1.1'

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
Expand Down Expand Up @@ -87,10 +87,12 @@ jobs:
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

- name: Log into registry ${{ env.DOCKER_REGISTRY }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
Expand Down
74 changes: 71 additions & 3 deletions src/blueprints/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def register_resource(client_id: str ):


@resources.route("/<client_id>/register-resources", methods=["OPTIONS", "POST"])
def register_and_protect_resources(client_id: str ):
def register_and_protect_resources(client_id: str, payload=None ):
"""payload = [{
"resource":{
"name": "resource1",
Expand All @@ -60,7 +60,8 @@ def register_and_protect_resources(client_id: str ):
},
"decisionStrategy": "UNANIMOUS"
}]"""
payload = request.get_json()
if payload == None:
payload = request.get_json()
policy_list = []

response_list = []
Expand Down Expand Up @@ -142,7 +143,6 @@ def delete_resource_and_policies(client_id: str, resource_name: str):
return custom_error(error.error_message, error.response_code)
except:
return custom_error("Unknown server error", 500)


@resources.route("/<client_id>/resources/<resource_id>", methods=["OPTIONS", "PUT"])
def update_resource(client_id: str, resource_id: str):
Expand All @@ -164,6 +164,74 @@ def delete_resource(client_id: str, resource_id: str):
return custom_error(error.error_message, error.response_code)
except:
return custom_error("Unknown server error", 500)

@resources.route("/create-client", methods=["POST"])
def create_client():
payload = request.get_json()
helper_text = """ The following fields are allowed:
clientId*: String
name: String
description: String
rootUrl: String
adminUrl: String
baseUrl: String
surrogateAuthRequired: Boolean
enabled: Boolean
alwaysDisplayInConsole: Boolean
clientAuthenticatorType: String
secret: String
registrationAccessToken: String
defaultRoles: List of [string]
redirectUris: List of [string]
webOrigins: List of [string]
notBefore: Integer
bearerOnly: Boolean
consentRequired: Boolean
standardFlowEnabled: Boolean
implicitFlowEnabled: Boolean
directAccessGrantsEnabled: Boolean
serviceAccountsEnabled: Boolean
oauth2DeviceAuthorizationGrantEnabled: Boolean
authorizationServicesEnabled: Boolean
directGrantsOnly: Boolean
publicClient: Boolean
frontchannelLogout: Boolean
protocol: String
attributes: Map of [string]
authenticationFlowBindingOverrides: Map of [string]
fullScopeAllowed: Boolean
nodeReRegistrationTimeout: Integer
registeredNodes: Map of [integer]
protocolMappers: List of ProtocolMapperRepresentation
clientTemplate: String
useTemplateConfig: Boolean
useTemplateScope: Boolean
useTemplateMappers: Boolean
defaultClientScopes: List of [string]
ClientScopes: List of [string]
authorizationSettings: ResourceServerRepresentation
access: Map of [boolean]
origin: String
resources: List of[Resource Representation]"""
if 'clientId' not in payload:
return custom_error("The field 'client_id' is mandatory", 400)
if 'redirectUris' not in payload:
payload['redirectUris'] = ['*']
if 'standardFlowEnabled' not in payload:
payload['standardFlowEnabled'] = True
if 'protocol' not in payload:
payload['protocol'] = 'openid-connect'
if 'resources' in payload:
resources = payload['resources']
del payload['resources']
keycloak_client.create_client(payload)
return register_and_protect_resources(payload['clientId'], resources)
try:
return keycloak_client.create_client(payload)
except KeycloakPostError as error:
return custom_error(error.error_message, error.response_code)
except:
return custom_error("Unknown server error", 500)

def custom_error(message, status_code):
return message, status_code
Expand Down