Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dinamis-sdk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CDOS-Pub
dinamis-sdk
Commits
9e5b45df
Commit
9e5b45df
authored
9 months ago
by
Cresson Remi
Browse files
Options
Downloads
Plain Diff
Merge branch 'add_bypass' into 'main'
Update 2 files See merge request
!18
parents
0f03a474
25ce727d
No related branches found
Branches containing commit
Tags
r0.1.10
Tags containing commit
1 merge request
!18
Update 2 files
Pipeline
#204874
passed with warnings
9 months ago
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dinamis_sdk/auth.py
+1
-1
1 addition, 1 deletion
dinamis_sdk/auth.py
dinamis_sdk/s3.py
+13
-2
13 additions, 2 deletions
dinamis_sdk/s3.py
dinamis_sdk/utils.py
+12
-8
12 additions, 8 deletions
dinamis_sdk/utils.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
27 additions
and
12 deletions
dinamis_sdk/auth.py
+
1
−
1
View file @
9e5b45df
...
@@ -59,7 +59,7 @@ class GrantMethodBase:
...
@@ -59,7 +59,7 @@ class GrantMethodBase:
"""
Base payload.
"""
"""
Base payload.
"""
return
{
return
{
"
client_id
"
:
self
.
client_id
,
"
client_id
"
:
self
.
client_id
,
"
scope
"
:
"
o
ffline_access
"
"
scope
"
:
"
o
penid
"
}
}
def
refresh_token
(
self
,
old_jwt
:
JWT
)
->
JWT
:
def
refresh_token
(
self
,
old_jwt
:
JWT
)
->
JWT
:
...
...
This diff is collapsed.
Click to expand it.
dinamis_sdk/s3.py
+
13
−
2
View file @
9e5b45df
...
@@ -26,8 +26,16 @@ from pystac_client import ItemSearch
...
@@ -26,8 +26,16 @@ from pystac_client import ItemSearch
import
packaging.version
import
packaging.version
import
pydantic
import
pydantic
from
.utils
import
log
,
SIGNED_URL_TTL_MARGIN
,
CREDENTIALS
,
MAX_URLS
,
\
from
.utils
import
(
S3_SIGNING_ENDPOINT
,
S3_STORAGE_DOMAIN
,
SIGNED_URL_DURATION_SECONDS
log
,
SIGNED_URL_TTL_MARGIN
,
CREDENTIALS
,
MAX_URLS
,
S3_SIGNING_ENDPOINT
,
S3_STORAGE_DOMAIN
,
SIGNED_URL_DURATION_SECONDS
,
BYPASS_API
)
_PYDANTIC_2_0
=
packaging
.
version
.
parse
(
_PYDANTIC_2_0
=
packaging
.
version
.
parse
(
pydantic
.
__version__
pydantic
.
__version__
...
@@ -35,6 +43,7 @@ _PYDANTIC_2_0 = packaging.version.parse(
...
@@ -35,6 +43,7 @@ _PYDANTIC_2_0 = packaging.version.parse(
AssetLike
=
TypeVar
(
"
AssetLike
"
,
Asset
,
Dict
[
str
,
Any
])
AssetLike
=
TypeVar
(
"
AssetLike
"
,
Asset
,
Dict
[
str
,
Any
])
# todo: fix the expression
asset_xpr
=
re
.
compile
(
asset_xpr
=
re
.
compile
(
r
"
https://(?P<account>[A-z0-9]+?)
"
r
"
https://(?P<account>[A-z0-9]+?)
"
r
"
\.minio-dinamis\.apps\.okd\.crocc\.meso\.umontpellier\.fr/
"
r
"
\.minio-dinamis\.apps\.okd\.crocc\.meso\.umontpellier\.fr/
"
...
@@ -443,6 +452,8 @@ def get_signed_urls(
...
@@ -443,6 +452,8 @@ def get_signed_urls(
"
dinamis-secret-key
"
:
CREDENTIALS
.
secret_key
"
dinamis-secret-key
"
:
CREDENTIALS
.
secret_key
})
})
log
.
debug
(
"
Using credentials (access/secret keys)
"
)
log
.
debug
(
"
Using credentials (access/secret keys)
"
)
elif
BYPASS_API
:
log
.
debug
(
"
Using bypass API %s
"
,
BYPASS_API
)
else
:
else
:
from
.auth
import
get_access_token
from
.auth
import
get_access_token
access_token
=
get_access_token
()
access_token
=
get_access_token
()
...
...
This diff is collapsed.
Click to expand it.
dinamis_sdk/utils.py
+
12
−
8
View file @
9e5b45df
...
@@ -6,11 +6,16 @@ import appdirs
...
@@ -6,11 +6,16 @@ import appdirs
from
pydantic
import
BaseModel
# pylint: disable = no-name-in-module
from
pydantic
import
BaseModel
# pylint: disable = no-name-in-module
import
requests
import
requests
# Env vars
ENV_TTL_MARGIN
=
"
DINAMIS_SDK_TTL_MARGIN
"
ENV_DURATION_SECS
=
"
DINAMIS_SDK_DURATION_SECONDS
"
ENV_BYPASS_API
=
"
DINAMIS_SDK_BYPASS_API
"
logging
.
basicConfig
(
level
=
os
.
environ
.
get
(
"
LOGLEVEL
"
)
or
"
INFO
"
)
logging
.
basicConfig
(
level
=
os
.
environ
.
get
(
"
LOGLEVEL
"
)
or
"
INFO
"
)
log
=
logging
.
getLogger
(
"
dinamis_sdk
"
)
log
=
logging
.
getLogger
(
"
dinamis_sdk
"
)
def
_get_seconds
(
env_var_name
:
str
,
default
:
int
)
->
int
:
def
_get_seconds
(
env_var_name
:
str
,
default
:
int
=
None
)
->
int
:
val
=
os
.
environ
.
get
(
env_var_name
)
val
=
os
.
environ
.
get
(
env_var_name
)
if
val
:
if
val
:
if
val
.
isdigit
():
if
val
.
isdigit
():
...
@@ -24,11 +29,8 @@ def _get_seconds(env_var_name: str, default: int) -> int:
...
@@ -24,11 +29,8 @@ def _get_seconds(env_var_name: str, default: int) -> int:
# Signed TTL margin default to 1800 seconds (30 minutes), or env. var.
# Signed TTL margin default to 1800 seconds (30 minutes), or env. var.
SIGNED_URL_TTL_MARGIN
=
_get_seconds
(
"
DINAMIS_SDK_TTL_MARGIN
"
,
1800
)
SIGNED_URL_TTL_MARGIN
=
_get_seconds
(
ENV_TTL_MARGIN
,
1800
)
SIGNED_URL_DURATION_SECONDS
=
_get_seconds
(
SIGNED_URL_DURATION_SECONDS
=
_get_seconds
(
ENV_DURATION_SECS
)
"
DINAMIS_SDK_DURATION_SECONDS
"
,
None
)
MAX_URLS
=
64
MAX_URLS
=
64
S3_STORAGE_DOMAIN
=
"
meso.umontpellier.fr
"
S3_STORAGE_DOMAIN
=
"
meso.umontpellier.fr
"
...
@@ -83,12 +85,14 @@ def retrieve_token_endpoint(s3_signing_endpoint: str = S3_SIGNING_ENDPOINT):
...
@@ -83,12 +85,14 @@ def retrieve_token_endpoint(s3_signing_endpoint: str = S3_SIGNING_ENDPOINT):
return
oauth2_defs
[
"
flows
"
][
"
password
"
][
"
tokenUrl
"
]
return
oauth2_defs
[
"
flows
"
][
"
password
"
][
"
tokenUrl
"
]
BYPASS_API
=
os
.
environ
.
get
(
ENV_BYPASS_API
)
# Token endpoint is typically something like: https://keycloak-dinamis.apps.okd
# Token endpoint is typically something like: https://keycloak-dinamis.apps.okd
# .crocc.meso.umontpellier.fr/auth/realms/dinamis/protocol/openid-connect/token
# .crocc.meso.umontpellier.fr/auth/realms/dinamis/protocol/openid-connect/token
TOKEN_ENDPOINT
=
retrieve_token_endpoint
()
TOKEN_ENDPOINT
=
None
if
BYPASS_API
else
retrieve_token_endpoint
()
# Auth base URL is typically something like: https://keycloak-dinamis.apps.okd.
# Auth base URL is typically something like: https://keycloak-dinamis.apps.okd.
# crocc.meso.umontpellier.fr/auth/realms/dinamis/protocol/openid-connect
# crocc.meso.umontpellier.fr/auth/realms/dinamis/protocol/openid-connect
AUTH_BASE_URL
=
TOKEN_ENDPOINT
.
rsplit
(
'
/
'
,
1
)[
0
]
AUTH_BASE_URL
=
None
if
BYPASS_API
else
TOKEN_ENDPOINT
.
rsplit
(
'
/
'
,
1
)[
0
]
# Token server (optional)
# Token server (optional)
TOKEN_SERVER
=
os
.
environ
.
get
(
"
DINAMIS_SDK_TOKEN_SERVER
"
)
TOKEN_SERVER
=
os
.
environ
.
get
(
"
DINAMIS_SDK_TOKEN_SERVER
"
)
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
9e5b45df
...
@@ -12,7 +12,7 @@ install_requires = [
...
@@ -12,7 +12,7 @@ install_requires = [
setup
(
setup
(
name
=
"
dinamis-sdk
"
,
name
=
"
dinamis-sdk
"
,
version
=
"
0.1.
9
"
,
version
=
"
0.1.
10
"
,
description
=
"
DINAMIS SDK
"
,
description
=
"
DINAMIS SDK
"
,
python_requires
=
"
>=3.8
"
,
python_requires
=
"
>=3.8
"
,
author
=
"
Remi Cresson
"
,
author
=
"
Remi Cresson
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment