-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#200: Provide endpoint with info for sda-cli login
- Loading branch information
Showing
9 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
mkdir -p keys | ||
|
||
openssl genrsa -out c4gh_key.sec.pem 4096 | ||
openssl rsa -in c4gh_key.sec.pem -pubout -out keys/c4gh_key.pub.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/kataras/iris/v12" | ||
"github.com/neicnordic/crypt4gh/keys" | ||
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 readPublicKeyFile(filename string) (key *[32]byte, err error) { | ||
log.Info("Reading Public key file") | ||
file, err := os.Open(filepath.Clean(filename)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer file.Close() | ||
publicKey, err := keys.ReadPublicKey(file) | ||
if err != nil { | ||
return nil, fmt.Errorf("error while reading public key file %s: %v", filename, err) | ||
} | ||
|
||
return &publicKey, err | ||
} | ||
|
||
func (auth AuthHandler) getInfo(ctx iris.Context) { | ||
publicKey, err := readPublicKeyFile(auth.Config.C4ghPubKey) | ||
if err != nil { | ||
log.Error("Failure to get public key: ", err) | ||
} | ||
pub := hex.EncodeToString(publicKey[:]) | ||
|
||
info := Info{ClientID: auth.OAuth2Config.ClientID, OidcURI: auth.Config.JwtIssuer, PublicKey: pub, InboxURI: auth.Config.S3Inbox} | ||
err = ctx.JSON(info) | ||
if err != nil { | ||
log.Error("Failure to get Info ", err) | ||
|
||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters