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

Project info text and URL made configurable #319

Merged
merged 6 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
4 changes: 4 additions & 0 deletions charts/sda-svc/templates/auth-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ spec:
{{- end }}
- name: S3INBOX
value: {{ .Values.global.ingress.hostName.s3Inbox }}
- name: INFOTEXT
value: {{ .Values.global.auth.infoText }}
- name: INFOURL
value: {{ .Values.global.auth.inforURL }}
ports:
- name: auth
containerPort: 8080
Expand Down
4 changes: 4 additions & 0 deletions charts/sda-svc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ global:
corsMethods: ""
# @param corsCreds, allow credentials in the request, cors is disabled if false
corsCreds: false
# @param infoText, name of the project
infoText: "Example project"
# @param inforURL, URL of the project
inforURL: " https://example.com/project"
shreyasshivakumara marked this conversation as resolved.
Show resolved Hide resolved

broker:
durable: true
Expand Down
4 changes: 4 additions & 0 deletions sda-auth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type Config struct {
Server ServerConfig
S3Inbox string
ResignJwt bool
InfoURL string
InfoText string
}

// NewConfig initializes and parses the config file and/or environment using
Expand Down Expand Up @@ -90,6 +92,8 @@ func (c *Config) readConfig() error {
c.JwtPrivateKey = viper.GetString("JwtPrivateKey")
c.JwtSignatureAlg = viper.GetString("JwtSignatureAlg")
c.JwtIssuer = viper.GetString("jwtIssuer")
c.InfoURL = viper.GetString("infoUrl")
c.InfoText = viper.GetString("infoText")

viper.SetDefault("ResignJwt", true)
c.ResignJwt = viper.GetBool("resignJwt")
Expand Down
2 changes: 2 additions & 0 deletions sda-auth/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ jwtIssuer: "http://auth:8080"
jwtPrivateKey: "keys/sign-jwt.key"
jwtSignatureAlg: "ES256"
resignJwt: true
infoText: "About LEGA"
infoUrl: "https://elixir-europe.org/internal-projects/staff-exchange-programme/localfederated-ega"
2 changes: 1 addition & 1 deletion sda-auth/frontend/templates/ega.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://elixir-europe.org/about-us/staff-exchange-programme/localfederated-ega">About LocalEGA</a>
<a class="nav-link" href="{{.infoUrl}}">{{.infoText}}</a>
</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sda-auth/frontend/templates/elixir.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://elixir-europe.org/about-us/staff-exchange-programme/localfederated-ega">About LocalEGA</a>
<a class="nav-link" href="{{.infoUrl}}">{{.infoText}}</a>
</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sda-auth/frontend/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://elixir-europe.org/about-us/staff-exchange-programme/localfederated-ega">About LocalEGA</a>
<a class="nav-link" href="{{.infoUrl}}">{{.infoText}}</a>
</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sda-auth/frontend/templates/loginform.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://elixir-europe.org/about-us/staff-exchange-programme/localfederated-ega">About LocalEGA</a>
<a class="nav-link" href="{{.infoUrl}}">{{.infoText}}</a>
</li>
</ul>
</div>
Expand Down
10 changes: 10 additions & 0 deletions sda-auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func (auth AuthHandler) getInboxConfig(ctx iris.Context, authType string) {
// getMain returns the index.html page
func (auth AuthHandler) getMain(ctx iris.Context) {

ctx.ViewData("infoUrl", auth.Config.InfoURL)
ctx.ViewData("infoText", auth.Config.InfoText)
err := ctx.View("index.html")
if err != nil {
log.Error("Failed to view index page: ", err)
Expand Down Expand Up @@ -150,6 +152,8 @@ func (auth AuthHandler) postEGA(ctx iris.Context) {
s3conf := getS3ConfigMap(token, auth.Config.S3Inbox, username)
idStruct := EGAIdentity{User: username, Token: token, ExpDate: expDate}
s.SetFlash("ega", s3conf)
ctx.ViewData("infoUrl", auth.Config.InfoURL)
ctx.ViewData("infoText", auth.Config.InfoText)
err = ctx.View("ega.html", idStruct)
if err != nil {
log.Error("Failed to parse response: ", err)
Expand Down Expand Up @@ -181,6 +185,8 @@ func (auth AuthHandler) getEGALogin(ctx iris.Context) {
s := sessions.Get(ctx)
message := s.GetFlashString("message")
if message == "" {
ctx.ViewData("infoUrl", auth.Config.InfoURL)
ctx.ViewData("infoText", auth.Config.InfoText)
err := ctx.View("loginform.html")
if err != nil {
log.Error("Failed to return to login form: ", err)
Expand All @@ -190,6 +196,8 @@ func (auth AuthHandler) getEGALogin(ctx iris.Context) {

return
}
ctx.ViewData("infoUrl", auth.Config.InfoURL)
ctx.ViewData("infoText", auth.Config.InfoText)
err := ctx.View("loginform.html", EGALoginError{Reason: message})
if err != nil {
log.Error("Failed to view invalid credentials form: ", err)
Expand Down Expand Up @@ -284,6 +292,8 @@ func (auth AuthHandler) getElixirLogin(ctx iris.Context) {

s := sessions.Get(ctx)
s.SetFlash("elixir", oidcData.S3Conf)
ctx.ViewData("infoUrl", auth.Config.InfoURL)
ctx.ViewData("infoText", auth.Config.InfoText)
err := ctx.View("elixir.html", oidcData.ElixirID)
if err != nil {
log.Error("Failed to view login form: ", err)
Expand Down
Loading