Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
backoffice_server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
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
web-et-numerique
Factory
LLLE_Project
backoffice_server
Commits
68d363be
Commit
68d363be
authored
4 months ago
by
Pierre Ecarlat
Browse files
Options
Downloads
Patches
Plain Diff
Added global variable to condition GRDF call
parent
99066c3a
No related branches found
No related tags found
3 merge requests
!120
feat: Allow to download all consents
,
!117
chore: Set GRDF token refresh as an option
,
!115
feat: Add the ability to deactivate GRDF token
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.env.template
+1
-0
1 addition, 0 deletions
.env.template
.gitlab-ci.yml
+2
-0
2 additions, 0 deletions
.gitlab-ci.yml
k8s/secrets/ecolyo-agent-server-config.yml
+1
-0
1 addition, 0 deletions
k8s/secrets/ecolyo-agent-server-config.yml
main.go
+23
-18
23 additions, 18 deletions
main.go
with
27 additions
and
18 deletions
.env.template
+
1
−
0
View file @
68d363be
...
@@ -22,5 +22,6 @@ DATABASE_NAME
...
@@ -22,5 +22,6 @@ DATABASE_NAME
BO_API_TOKEN
BO_API_TOKEN
FETCH_GRDF_TOKEN=true
GRDF_CLIENT_ID
GRDF_CLIENT_ID
GRDF_CLIENT_SECRET
GRDF_CLIENT_SECRET
This diff is collapsed.
Click to expand it.
.gitlab-ci.yml
+
2
−
0
View file @
68d363be
...
@@ -142,6 +142,7 @@ deploy_rec:
...
@@ -142,6 +142,7 @@ deploy_rec:
-
sed -i "s/{{CLIENT_ID}}/$REC_CLIENT_ID/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{CLIENT_ID}}/$REC_CLIENT_ID/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{CLIENT_SECRET}}/$REC_CLIENT_SECRET/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{CLIENT_SECRET}}/$REC_CLIENT_SECRET/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{BO_API_TOKEN}}/$REC_BO_API_TOKEN/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{BO_API_TOKEN}}/$REC_BO_API_TOKEN/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{FETCH_GRDF_TOKEN}}/$FETCH_GRDF_TOKEN/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{GRDF_CLIENT_ID}}/$GRDF_CLIENT_ID/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{GRDF_CLIENT_ID}}/$GRDF_CLIENT_ID/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{GRDF_CLIENT_SECRET}}/$GRDF_CLIENT_SECRET/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{GRDF_CLIENT_SECRET}}/$GRDF_CLIENT_SECRET/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{HOSTNAME}}/ecolyo-agent-rec.apps.grandlyon.com/g" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{HOSTNAME}}/ecolyo-agent-rec.apps.grandlyon.com/g" ./k8s/secrets/ecolyo-agent-server-config.yml
...
@@ -174,6 +175,7 @@ deploy_prod:
...
@@ -174,6 +175,7 @@ deploy_prod:
-
sed -i "s/{{CLIENT_ID}}/$PROD_CLIENT_ID/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{CLIENT_ID}}/$PROD_CLIENT_ID/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{CLIENT_SECRET}}/$PROD_CLIENT_SECRET/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{CLIENT_SECRET}}/$PROD_CLIENT_SECRET/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{BO_API_TOKEN}}/$PROD_BO_API_TOKEN/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{BO_API_TOKEN}}/$PROD_BO_API_TOKEN/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{FETCH_GRDF_TOKEN}}/$FETCH_GRDF_TOKEN/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{GRDF_CLIENT_ID}}/$GRDF_CLIENT_ID/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{GRDF_CLIENT_ID}}/$GRDF_CLIENT_ID/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{GRDF_CLIENT_SECRET}}/$GRDF_CLIENT_SECRET/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{GRDF_CLIENT_SECRET}}/$GRDF_CLIENT_SECRET/" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{HOSTNAME}}/ecolyo-agent.apps.grandlyon.com/g" ./k8s/secrets/ecolyo-agent-server-config.yml
-
sed -i "s/{{HOSTNAME}}/ecolyo-agent.apps.grandlyon.com/g" ./k8s/secrets/ecolyo-agent-server-config.yml
...
...
This diff is collapsed.
Click to expand it.
k8s/secrets/ecolyo-agent-server-config.yml
+
1
−
0
View file @
68d363be
...
@@ -20,6 +20,7 @@ stringData:
...
@@ -20,6 +20,7 @@ stringData:
BO_API_TOKEN
:
{{
BO_API_TOKEN
}}
BO_API_TOKEN
:
{{
BO_API_TOKEN
}}
TOKEN_URL
:
{{
TOKEN_URL
}}
TOKEN_URL
:
{{
TOKEN_URL
}}
USERINFO_URL
:
{{
USERINFO_URL
}}
USERINFO_URL
:
{{
USERINFO_URL
}}
FETCH_GRDF_TOKEN
:
{{
FETCH_GRDF_TOKEN
}}
GRDF_CLIENT_ID
:
{{
GRDF_CLIENT_ID
}}
GRDF_CLIENT_ID
:
{{
GRDF_CLIENT_ID
}}
GRDF_CLIENT_SECRET
:
{{
GRDF_CLIENT_SECRET
}}
GRDF_CLIENT_SECRET
:
{{
GRDF_CLIENT_SECRET
}}
type
:
Opaque
type
:
Opaque
This diff is collapsed.
Click to expand it.
main.go
+
23
−
18
View file @
68d363be
...
@@ -16,9 +16,10 @@ import (
...
@@ -16,9 +16,10 @@ import (
)
)
var
(
var
(
httpsPort
=
common
.
IntValueFromEnv
(
"HTTPS_PORT"
,
443
)
// HTTPS port to serve on
httpsPort
=
common
.
IntValueFromEnv
(
"HTTPS_PORT"
,
443
)
// HTTPS port to serve on
debugMode
=
common
.
BoolValueFromEnv
(
"DEBUG_MODE"
,
false
)
// Debug mode, disable Secure attribute for cookies
debugMode
=
common
.
BoolValueFromEnv
(
"DEBUG_MODE"
,
false
)
// Debug mode, disable Secure attribute for cookies
mockOAuth2
=
common
.
BoolValueFromEnv
(
"MOCK_OAUTH2"
,
false
)
// Enable mock OAuth2 login
mockOAuth2
=
common
.
BoolValueFromEnv
(
"MOCK_OAUTH2"
,
false
)
// Enable mock OAuth2 login
fetchGrdfToken
=
common
.
BoolValueFromEnv
(
"FETCH_GRDF_TOKEN"
,
true
)
// HTTPS port to serve on
)
)
func
main
()
{
func
main
()
{
...
@@ -41,23 +42,27 @@ func main() {
...
@@ -41,23 +42,27 @@ func main() {
fmt
.
Println
(
"Mock OAuth2 server Listening on: http://localhost"
+
mockOAuth2Port
)
fmt
.
Println
(
"Mock OAuth2 server Listening on: http://localhost"
+
mockOAuth2Port
)
}
}
// Call the function immediately when the server starts
models
.
FetchGRDFAuthAPI
()
// then call GRDF auth api every two hours
ticker
:=
time
.
NewTicker
(
time
.
Hour
*
2
)
quit
:=
make
(
chan
struct
{})
quit
:=
make
(
chan
struct
{})
go
func
()
{
for
{
// If needed, we shall request a new GRDF token every 2-hours
select
{
if
fetchGrdfToken
{
case
<-
ticker
.
C
:
// Call the function immediately when the server starts
models
.
FetchGRDFAuthAPI
()
models
.
FetchGRDFAuthAPI
()
case
<-
quit
:
ticker
.
Stop
()
// then call GRDF auth api every two hours
return
ticker
:=
time
.
NewTicker
(
time
.
Hour
*
2
)
go
func
()
{
for
{
select
{
case
<-
ticker
.
C
:
models
.
FetchGRDFAuthAPI
()
case
<-
quit
:
ticker
.
Stop
()
return
}
}
}
}
}
()
}
()
}
// Deletes outdated consents every 24h
// Deletes outdated consents every 24h
dh
:=
models
.
NewDataHandler
()
dh
:=
models
.
NewDataHandler
()
...
...
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