From aa2df1789353d3a42f098fccbff636e292882f6d Mon Sep 17 00:00:00 2001 From: Panos Chatzopoulos Date: Mon, 26 Jun 2023 15:17:45 +0200 Subject: [PATCH] #200: Provide endpoint with info for sda-cli login --- sda-auth/info.go | 28 ++++++++++++++++++++++++++++ sda-auth/main.go | 1 + 2 files changed, 29 insertions(+) create mode 100644 sda-auth/info.go diff --git a/sda-auth/info.go b/sda-auth/info.go new file mode 100644 index 000000000..e1634cf26 --- /dev/null +++ b/sda-auth/info.go @@ -0,0 +1,28 @@ +package main + +import ( + "github.com/kataras/iris/v12" + log "github.com/sirupsen/logrus" +) + +type Info struct { + ClientID string `json:"client_id"` + OidcURI string `json:"oidc_uri"` + PublicKey string `json:"public_key"` + InboxURI string `json:"inbox_uri"` +} + +func (auth AuthHandler) getInfo(ctx iris.Context) { + log.Println("in getInfo") + + if auth.OAuth2Config.ClientID != "" && auth.Config.JwtIssuer != "" && auth.Config.S3Inbox != "" { + info := Info{ClientID: auth.OAuth2Config.ClientID, OidcURI: auth.Config.JwtIssuer, PublicKey: "todo.pub", InboxURI: auth.Config.S3Inbox} + //infoJ, err := json.Marshal(info) + err := ctx.JSON(info) + if err != nil { + log.Error("Failure to get Info ", err) + + return + } + } +} diff --git a/sda-auth/main.go b/sda-auth/main.go index 6bd384234..a17009eeb 100644 --- a/sda-auth/main.go +++ b/sda-auth/main.go @@ -389,6 +389,7 @@ func main() { app.Get("/elixir/s3conf", authHandler.getElixirConf) app.Get("/elixir/login", authHandler.getElixirLogin) app.Get("/elixir/cors_login", authHandler.getElixirCORSLogin) + app.Get("/info", authHandler.getInfo) app.UseGlobal(globalHeaders)