Skip to content
Snippets Groups Projects
Commit a6523936 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

return access type in auth response

parent b2188bbb
No related branches found
No related tags found
No related merge requests found
...@@ -126,6 +126,7 @@ func alwaysAllowed(creds SourceCredentials) (beamtimeMeta, bool) { ...@@ -126,6 +126,7 @@ func alwaysAllowed(creds SourceCredentials) (beamtimeMeta, bool) {
if pair.BeamtimeId == creds.BeamtimeId { if pair.BeamtimeId == creds.BeamtimeId {
pair.DataSource = creds.DataSource pair.DataSource = creds.DataSource
pair.Type = creds.Type pair.Type = creds.Type
pair.AccessType = "write"
return pair, true return pair, true
} }
} }
...@@ -152,26 +153,37 @@ func needHostAuthorization(creds SourceCredentials) bool { ...@@ -152,26 +153,37 @@ func needHostAuthorization(creds SourceCredentials) bool {
return creds.Type == "raw" || len(creds.Token) == 0 return creds.Type == "raw" || len(creds.Token) == 0
} }
func authorizeByToken(creds SourceCredentials) error { func checkToken(token string, subject_expect string) (accessType string, err error) {
var token_expect string claims,err := Auth.UserAuth().CheckAndGetContent(token)
if (creds.BeamtimeId != "auto") { if err!=nil {
token_expect, _ = Auth.UserAuth().GenerateToken(&creds.BeamtimeId) return "",err
} else {
key := "bl_" + creds.Beamline
token_expect, _ = Auth.UserAuth().GenerateToken(&key)
} }
var err_string string cclaims,ok:=claims.(*utils.CustomClaims)
if creds.Token != token_expect { if !ok {
if creds.BeamtimeId != "auto" { return "",errors.New("wrong token claims")
err_string = "wrong token for beamtime " + creds.BeamtimeId
} else {
err_string = "wrong token for beamline " + creds.Beamline
}
log.Error(err_string)
return errors.New(err_string)
} }
return nil if cclaims.Subject!=subject_expect {
return "",errors.New("wrong token for "+subject_expect)
}
var extra_claim utils.AccessTokenExtraClaim
ecMap,ok:=cclaims.ExtraClaims.(map[string]interface{})
if !ok {
return "",errors.New("wrong token extra claims")
}
err = utils.MapToStruct(ecMap, &extra_claim)
return extra_claim.AccessType,err
}
func authorizeByToken(creds SourceCredentials) (accessType string, err error) {
subject_expect:=""
if (creds.BeamtimeId != "auto") {
subject_expect = "bt_"+creds.BeamtimeId
} else {
subject_expect = "bl_" + creds.Beamline
}
return checkToken(creds.Token,subject_expect)
} }
func findMeta(creds SourceCredentials) (beamtimeMeta, error) { func findMeta(creds SourceCredentials) (beamtimeMeta, error) {
...@@ -204,31 +216,30 @@ func findMeta(creds SourceCredentials) (beamtimeMeta, error) { ...@@ -204,31 +216,30 @@ func findMeta(creds SourceCredentials) (beamtimeMeta, error) {
return meta, nil return meta, nil
} }
func authorizeMeta(meta beamtimeMeta, request authorizationRequest, creds SourceCredentials) error { func authorizeMeta(meta beamtimeMeta, request authorizationRequest, creds SourceCredentials) (accessType string, err error) {
accessType = ""
if creds.Type=="raw" && meta.OnlinePath=="" { if creds.Type=="raw" && meta.OnlinePath=="" {
err_string := "beamtime "+meta.BeamtimeId+" is not online" err_string := "beamtime "+meta.BeamtimeId+" is not online"
log.Error(err_string) log.Error(err_string)
return errors.New(err_string) return "",errors.New(err_string)
} }
if creds.Beamline != "auto" && meta.Beamline != creds.Beamline { if creds.Beamline != "auto" && meta.Beamline != creds.Beamline {
err_string := "given beamline (" + creds.Beamline + ") does not match the found one (" + meta.Beamline + ")" err_string := "given beamline (" + creds.Beamline + ") does not match the found one (" + meta.Beamline + ")"
log.Debug(err_string) log.Debug(err_string)
return errors.New(err_string) return "",errors.New(err_string)
} }
if needHostAuthorization(creds) { if needHostAuthorization(creds) {
if err := authorizeByHost(request.OriginHost, meta.Beamline); err != nil { if err := authorizeByHost(request.OriginHost, meta.Beamline); err != nil {
return err return "",err
} }
accessType = "write"
} else { } else {
if err := authorizeByToken(creds); err != nil { accessType,err = authorizeByToken(creds)
return err
}
} }
return nil return accessType,err
} }
func authorize(request authorizationRequest, creds SourceCredentials) (beamtimeMeta, error) { func authorize(request authorizationRequest, creds SourceCredentials) (beamtimeMeta, error) {
...@@ -241,11 +252,14 @@ func authorize(request authorizationRequest, creds SourceCredentials) (beamtimeM ...@@ -241,11 +252,14 @@ func authorize(request authorizationRequest, creds SourceCredentials) (beamtimeM
return beamtimeMeta{}, err return beamtimeMeta{}, err
} }
if err := authorizeMeta(meta, request, creds); err != nil { var accessType string
if accessType, err = authorizeMeta(meta, request, creds); err != nil {
return beamtimeMeta{}, err return beamtimeMeta{}, err
} }
log.Debug("authorized beamtime " + meta.BeamtimeId + " for " + request.OriginHost + " in " + meta.Beamline+", type "+meta.Type) meta.AccessType = accessType
log.Debug("authorized beamtime " + meta.BeamtimeId + " for " + request.OriginHost + " in " +
meta.Beamline+", type "+meta.Type +"access type: "+accessType)
return meta, nil return meta, nil
} }
......
...@@ -16,9 +16,14 @@ import ( ...@@ -16,9 +16,14 @@ import (
) )
func prepareToken(payload string) string{ func prepareUserToken(payload string, accessType string) string{
Auth = authorization.NewAuth(utils.NewHMACAuth("secret"),nil,nil) Auth = authorization.NewAuth(nil,utils.NewJWTAuth("secret_user"),nil)
token, _ := Auth.UserAuth().GenerateToken(&payload) var claims utils.CustomClaims
var extraClaim utils.AccessTokenExtraClaim
claims.Subject = payload
extraClaim.AccessType = accessType
claims.ExtraClaims = &extraClaim
token, _ := Auth.AdminAuth().GenerateToken(&claims)
return token return token
} }
...@@ -103,7 +108,7 @@ func TestSplitCreds(t *testing.T) { ...@@ -103,7 +108,7 @@ func TestSplitCreds(t *testing.T) {
} }
func TestAuthorizeDefaultOK(t *testing.T) { func TestAuthorizeDefaultOK(t *testing.T) {
allowBeamlines([]beamtimeMeta{{"asapo_test","beamline","","2019","tf",""}}) allowBeamlines([]beamtimeMeta{{"asapo_test","beamline","","2019","tf","",""}})
request := makeRequest(authorizationRequest{"processed%asapo_test%%%","host"}) request := makeRequest(authorizationRequest{"processed%asapo_test%%%","host"})
w := doPostRequest("/authorize",request,"") w := doPostRequest("/authorize",request,"")
...@@ -174,38 +179,38 @@ var authTests = [] struct { ...@@ -174,38 +179,38 @@ var authTests = [] struct {
message string message string
answer string answer string
}{ }{
{"processed","test","auto","dataSource", prepareToken("test"),"127.0.0.2",http.StatusOK,"user source with correct token", {"processed","test","auto","dataSource", prepareUserToken("bt_test","write"),"127.0.0.2",http.StatusOK,"user source with correct token",
`{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed"}`}, `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-type":"write"}`},
{"processed","test_online","auto","dataSource", prepareToken("test_online"),"127.0.0.1",http.StatusOK,"with online path, processed type", {"processed","test_online","auto","dataSource", prepareUserToken("bt_test_online","read"),"127.0.0.1",http.StatusOK,"with online path, processed type",
`{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"","source-type":"processed"}`}, `{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"","source-type":"processed","access-type":"read"}`},
{"processed","test1","auto","dataSource", prepareToken("test1"),"127.0.0.1",http.StatusUnauthorized,"correct token, beamtime not found", {"processed","test1","auto","dataSource", prepareUserToken("bt_test1","read"),"127.0.0.1",http.StatusUnauthorized,"correct token, beamtime not found",
""}, ""},
{"processed","test","auto","dataSource", prepareToken("wrong"),"127.0.0.1",http.StatusUnauthorized,"user source with wrong token", {"processed","test","auto","dataSource", prepareUserToken("wrong","read"),"127.0.0.1",http.StatusUnauthorized,"user source with wrong token",
""}, ""},
{"processed","test","bl1","dataSource", prepareToken("test"),"127.0.0.1",http.StatusOK,"correct beamline given", {"processed","test","bl1","dataSource", prepareUserToken("bt_test","read"),"127.0.0.1",http.StatusOK,"correct beamline given",
`{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed"}`}, `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-type":"read"}`},
{"processed","test","bl2","dataSource", prepareToken("test"),"127.0.0.1",http.StatusUnauthorized,"incorrect beamline given", {"processed","test","bl2","dataSource", prepareUserToken("bt_test","read"),"127.0.0.1",http.StatusUnauthorized,"incorrect beamline given",
""}, ""},
{"processed","auto","p07", "dataSource",prepareToken("bl_p07"),"127.0.0.1",http.StatusOK,"beamtime found", {"processed","auto","p07", "dataSource", prepareUserToken("bl_p07","read"),"127.0.0.1",http.StatusOK,"beamtime found",
`{"beamtimeId":"11111111","beamline":"p07","dataSource":"dataSource","core-path":"asap3/petra3/gpfs/p07/2020/data/11111111","beamline-path":"","source-type":"processed"}`}, `{"beamtimeId":"11111111","beamline":"p07","dataSource":"dataSource","core-path":"asap3/petra3/gpfs/p07/2020/data/11111111","beamline-path":"","source-type":"processed","access-type":"read"}`},
{"processed","auto","p07", "dataSource",prepareToken("bl_p06"),"127.0.0.1",http.StatusUnauthorized,"wrong token", {"processed","auto","p07", "dataSource", prepareUserToken("bl_p06","read"),"127.0.0.1",http.StatusUnauthorized,"wrong token",
""}, ""},
{"processed","auto","p08", "dataSource",prepareToken("bl_p08"),"127.0.0.1",http.StatusUnauthorized,"beamtime not found", {"processed","auto","p08", "dataSource", prepareUserToken("bl_p08","read"),"127.0.0.1",http.StatusUnauthorized,"beamtime not found",
""}, ""},
{"raw","test_online","auto","dataSource", prepareToken("test_online"),"127.0.0.1",http.StatusOK,"raw type",
`{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"./bl1/current","source-type":"raw"}`},
{"raw","test_online","auto","dataSource", "","127.0.0.1",http.StatusOK,"raw type", {"raw","test_online","auto","dataSource", "","127.0.0.1",http.StatusOK,"raw type",
`{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"./bl1/current","source-type":"raw"}`}, `{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"./bl1/current","source-type":"raw","access-type":"write"}`},
{"raw","test_online","auto","dataSource", "","127.0.0.1",http.StatusOK,"raw type",
`{"beamtimeId":"test_online","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test_online","beamline-path":"./bl1/current","source-type":"raw","access-type":"write"}`},
{"raw","auto","p07","dataSource", "","127.0.0.1",http.StatusOK,"raw type, auto beamtime", {"raw","auto","p07","dataSource", "","127.0.0.1",http.StatusOK,"raw type, auto beamtime",
`{"beamtimeId":"11111111","beamline":"p07","dataSource":"dataSource","core-path":"asap3/petra3/gpfs/p07/2020/data/11111111","beamline-path":"./p07/current","source-type":"raw"}`}, `{"beamtimeId":"11111111","beamline":"p07","dataSource":"dataSource","core-path":"asap3/petra3/gpfs/p07/2020/data/11111111","beamline-path":"./p07/current","source-type":"raw","access-type":"write"}`},
{"raw","auto","p07","noldap", "","127.0.0.1",http.StatusNotFound,"no conection to ldap", {"raw","auto","p07","noldap", "","127.0.0.1",http.StatusNotFound,"no conection to ldap",
""}, ""},
{"raw","test_online","auto","dataSource", "","127.0.0.2",http.StatusUnauthorized,"raw type, wrong origin host", {"raw","test_online","auto","dataSource", "","127.0.0.2",http.StatusUnauthorized,"raw type, wrong origin host",
""}, ""},
{"raw","test","auto","dataSource", prepareToken("test"),"127.0.0.1",http.StatusUnauthorized,"raw when not online", {"raw","test","auto","dataSource", prepareUserToken("bt_test","read"),"127.0.0.1",http.StatusUnauthorized,"raw when not online",
""}, ""},
{"processed","test","auto","dataSource", "","127.0.0.1:1001",http.StatusOK,"processed without token", {"processed","test","auto","dataSource", "","127.0.0.1:1001",http.StatusOK,"processed without token",
`{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed"}`}, `{"beamtimeId":"test","beamline":"bl1","dataSource":"dataSource","core-path":"./tf/gpfs/bl1/2019/data/test","beamline-path":"","source-type":"processed","access-type":"write"}`},
{"processed","test","auto","dataSource", "","127.0.0.2",http.StatusUnauthorized,"processed without token, wrong host", {"processed","test","auto","dataSource", "","127.0.0.2",http.StatusUnauthorized,"processed without token, wrong host",
""}, ""},
} }
...@@ -213,7 +218,7 @@ var authTests = [] struct { ...@@ -213,7 +218,7 @@ var authTests = [] struct {
func TestAuthorize(t *testing.T) { func TestAuthorize(t *testing.T) {
ldapClient = mockClient ldapClient = mockClient
allowBeamlines([]beamtimeMeta{}) allowBeamlines([]beamtimeMeta{})
Auth = authorization.NewAuth(utils.NewHMACAuth("secret"),utils.NewHMACAuth("secret"),utils.NewJWTAuth("secret")) Auth = authorization.NewAuth(utils.NewJWTAuth("secret_user"),utils.NewJWTAuth("secret_admin"),utils.NewJWTAuth("secret"))
expected_uri := "expected_uri" expected_uri := "expected_uri"
expected_base := "expected_base" expected_base := "expected_base"
allowed_ips := []string{"127.0.0.1"} allowed_ips := []string{"127.0.0.1"}
...@@ -282,7 +287,7 @@ func TestAuthorizeWrongPath(t *testing.T) { ...@@ -282,7 +287,7 @@ func TestAuthorizeWrongPath(t *testing.T) {
} }
func TestDoNotAuthorizeIfNotInAllowed(t *testing.T) { func TestDoNotAuthorizeIfNotInAllowed(t *testing.T) {
allowBeamlines([]beamtimeMeta{{"test","beamline","","2019","tf",""}}) allowBeamlines([]beamtimeMeta{{"test","beamline","","2019","tf","",""}})
request := authorizationRequest{"asapo_test%%","host"} request := authorizationRequest{"asapo_test%%","host"}
creds,_ := getSourceCredentials(request) creds,_ := getSourceCredentials(request)
......
...@@ -39,14 +39,8 @@ func folderTokenResponce(token string) []byte{ ...@@ -39,14 +39,8 @@ func folderTokenResponce(token string) []byte{
} }
func checkBeamtimeToken(request folderTokenRequest) error { func checkBeamtimeToken(request folderTokenRequest) error {
token_expect, _ := Auth.UserAuth().GenerateToken(&request.BeamtimeId) _,err := checkToken(request.Token,"bt_"+request.BeamtimeId)
var err_string string return err
if request.Token != token_expect {
err_string = "wrong token for beamtime " + request.BeamtimeId
log.Error(err_string)
return errors.New(err_string)
}
return nil
} }
......
...@@ -19,20 +19,20 @@ var fodlerTokenTests = [] struct { ...@@ -19,20 +19,20 @@ var fodlerTokenTests = [] struct {
status int status int
message string message string
}{ }{
{"test", "tf/gpfs/bl1/2019/data/test",prepareToken("test"),http.StatusOK,"beamtime found"}, {"test", "tf/gpfs/bl1/2019/data/test", prepareUserToken("bt_test","read"),http.StatusOK,"beamtime found"},
{"test_online", "bl1/current",prepareToken("test_online"),http.StatusOK,"online beamtime found"}, /* {"test_online", "bl1/current", prepareUserToken("bt_test_online","read"),http.StatusOK,"online beamtime found"},
{"test", "bl1/current",prepareToken("test"),http.StatusUnauthorized,"no online beamtime found"}, {"test", "bl1/current", prepareUserToken("bt_test","read"),http.StatusUnauthorized,"no online beamtime found"},
{"test_online", "bl2/current",prepareToken("test_online"),http.StatusUnauthorized,"wrong online folder"}, {"test_online", "bl2/current", prepareUserToken("bt_test_online","read"),http.StatusUnauthorized,"wrong online folder"},
{"test", "tf/gpfs/bl1/2019/data/test1",prepareToken("test"),http.StatusUnauthorized,"wrong folder"}, {"test", "tf/gpfs/bl1/2019/data/test1", prepareUserToken("bt_test","read"),http.StatusUnauthorized,"wrong folder"},
{"test", "tf/gpfs/bl1/2019/data/test",prepareToken("test1"),http.StatusUnauthorized,"wrong token"}, {"test", "tf/gpfs/bl1/2019/data/test", prepareUserToken("bt_test1","read"),http.StatusUnauthorized,"wrong token"},
{"11111111", "tf/gpfs/bl1/2019/data/test",prepareToken("11111111"),http.StatusBadRequest,"bad request"}, {"11111111", "tf/gpfs/bl1/2019/data/test", prepareUserToken("bt_11111111","read"),http.StatusBadRequest,"bad request"},*/
} }
func TestFolderToken(t *testing.T) { func TestFolderToken(t *testing.T) {
allowBeamlines([]beamtimeMeta{}) allowBeamlines([]beamtimeMeta{})
settings.RootBeamtimesFolder ="." settings.RootBeamtimesFolder ="."
settings.CurrentBeamlinesFolder="." settings.CurrentBeamlinesFolder="."
Auth = authorization.NewAuth(utils.NewHMACAuth("secret"),utils.NewHMACAuth("secret"),utils.NewJWTAuth("secret")) Auth = authorization.NewAuth(utils.NewJWTAuth("secret_user"),utils.NewJWTAuth("secret_admin"),utils.NewJWTAuth("secret_folder"))
os.MkdirAll(filepath.Clean("tf/gpfs/bl1/2019/data/test"), os.ModePerm) os.MkdirAll(filepath.Clean("tf/gpfs/bl1/2019/data/test"), os.ModePerm)
os.MkdirAll(filepath.Clean("tf/gpfs/bl1/2019/data/test_online"), os.ModePerm) os.MkdirAll(filepath.Clean("tf/gpfs/bl1/2019/data/test_online"), os.ModePerm)
...@@ -52,7 +52,7 @@ func TestFolderToken(t *testing.T) { ...@@ -52,7 +52,7 @@ func TestFolderToken(t *testing.T) {
w := doPostRequest("/folder",request,"") w := doPostRequest("/folder",request,"")
if w.Code == http.StatusOK { if w.Code == http.StatusOK {
body, _ := ioutil.ReadAll(w.Body) body, _ := ioutil.ReadAll(w.Body)
claims,_ := utils.CheckJWTToken(string(body),"secret") claims,_ := utils.CheckJWTToken(string(body),"secret_folder")
var extra_claim utils.FolderTokenTokenExtraClaim var extra_claim utils.FolderTokenTokenExtraClaim
utils.MapToStruct(claims.(*utils.CustomClaims).ExtraClaims.(map[string]interface{}), &extra_claim) utils.MapToStruct(claims.(*utils.CustomClaims).ExtraClaims.(map[string]interface{}), &extra_claim)
assert.Equal(t, abs_path, extra_claim.RootFolder, test.message) assert.Equal(t, abs_path, extra_claim.RootFolder, test.message)
......
...@@ -12,6 +12,7 @@ type beamtimeMeta struct { ...@@ -12,6 +12,7 @@ type beamtimeMeta struct {
OfflinePath string `json:"core-path"` OfflinePath string `json:"core-path"`
OnlinePath string `json:"beamline-path"` OnlinePath string `json:"beamline-path"`
Type string `json:"source-type"` Type string `json:"source-type"`
AccessType string `json:"access-type"`
} }
type serverSettings struct { type serverSettings struct {
......
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"errors" "errors"
"fmt"
"github.com/dgrijalva/jwt-go" "github.com/dgrijalva/jwt-go"
"net/http" "net/http"
"net/url" "net/url"
...@@ -31,6 +32,7 @@ type Auth interface { ...@@ -31,6 +32,7 @@ type Auth interface {
GenerateToken(...interface{}) (string, error) GenerateToken(...interface{}) (string, error)
ProcessAuth(http.HandlerFunc, string) http.HandlerFunc ProcessAuth(http.HandlerFunc, string) http.HandlerFunc
Name() string Name() string
CheckAndGetContent(token string, payload ...interface{}) (interface{}, error)
} }
...@@ -152,6 +154,17 @@ func ProcessJWTAuth(fn http.HandlerFunc, key string) http.HandlerFunc { ...@@ -152,6 +154,17 @@ func ProcessJWTAuth(fn http.HandlerFunc, key string) http.HandlerFunc {
} }
} }
func (a *JWTAuth) CheckAndGetContent(token string, payload ...interface{}) (interface{}, error) {
// payload ignored
claims, ok := CheckJWTToken(token,a.Key)
if !ok {
fmt.Println("hello ",token,a.Key)
return nil,errors.New("wrong JWT token")
}
return claims,nil
}
func CheckJWTToken(token, key string) (jwt.Claims, bool) { func CheckJWTToken(token, key string) (jwt.Claims, bool) {
if token == "" { if token == "" {
...@@ -249,6 +262,23 @@ func ProcessHMACAuth(fn http.HandlerFunc, payload, key string) http.HandlerFunc ...@@ -249,6 +262,23 @@ func ProcessHMACAuth(fn http.HandlerFunc, payload, key string) http.HandlerFunc
} }
} }
func (a *HMACAuth) CheckAndGetContent(token string, payload ...interface{}) (interface{}, error) {
if len(payload) != 1 {
return nil, errors.New("wrong payload")
}
value, ok := payload[0].(string)
if !ok {
return "", errors.New("wrong payload")
}
ok = CheckHMACToken(token,value,a.Key)
if !ok {
return nil,errors.New("wrong HMAC token")
}
return nil,nil
}
func CheckHMACToken(value string, token, key string) bool { func CheckHMACToken(value string, token, key string) bool {
if token == "" { if token == "" {
......
...@@ -21,31 +21,39 @@ cp beamtime-metadata* beamline/p07/current/ ...@@ -21,31 +21,39 @@ cp beamtime-metadata* beamline/p07/current/
#tokens #tokens
AdminToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMTNvcGpyaXB0MzNlb2ZjbWJuZyIsInN1YiI6ImFkbWluIiwiRXh0cmFDbGFpbXMiOnsiQWNjZXNzVHlwZSI6ImNyZWF0ZSJ9fQ.uRjtGPaRpOlOfKroijHRgMDNaZHnXsVPf0JaJ1XMg7o AdminToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMTNvcGpyaXB0MzNlb2ZjbWJuZyIsInN1YiI6ImFkbWluIiwiRXh0cmFDbGFpbXMiOnsiQWNjZXNzVHlwZSI6ImNyZWF0ZSJ9fQ.uRjtGPaRpOlOfKroijHRgMDNaZHnXsVPf0JaJ1XMg7o
curl -v --silent -H "Authorization: Bearer $AdminToken" --data '{"Subject": {"beamtimeId":"12345678"},"DaysValid":123,"AccessType":"read"}' 127.0.0.1:5007/admin/issue --stderr - | tee /dev/stderr | grep "bt_12345678" #curl -v --silent -H "Authorization: Bearer $AdminToken" --data '{"Subject": {"beamtimeId":"12345678"},"DaysValid":123,"AccessType":"read"}' 127.0.0.1:5007/admin/issue --stderr - | tee /dev/stderr | grep "bt_12345678"
curl -v --silent -H "Authorization: Bearer blabla" --data '{"Subject": {"beamtimeId":"12345678"},"DaysValid":123,"AccessType":"read"}' 127.0.0.1:5007/admin/issue --stderr - | tee /dev/stderr | grep "token does not match" #curl -v --silent -H "Authorization: Bearer blabla" --data '{"Subject": {"beamtimeId":"12345678"},"DaysValid":123,"AccessType":"read"}' 127.0.0.1:5007/admin/issue --stderr - | tee /dev/stderr | grep "token does not match"
curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep c20180508-000-COM20181 #curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr - #| tee /dev/stderr | grep c20180508-000-COM20181
curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep p00 #curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep p00
curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep detector #curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep detector
token=onm80KQF8s6d2p_laW0S5IYanUUsLcnB3QO-6QQ1M90= #token for c20180508-000-COM20181 token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMTNxZWpyaXB0MzUybHQxNjhyZyIsInN1YiI6ImJ0X2MyMDE4MDUwOC0wMDAtQ09NMjAxODEiLCJFeHRyYUNsYWltcyI6eyJBY2Nlc3NUeXBlIjoicmVhZCJ9fQ.MDuQa_f0yOcn35xIgiCfoVVT56oTQ5tSiuKu9VqO_tE #token for c20180508-000-COM20181
curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%onm80KQF8s6d2p_laW0S5IYanUUsLcnB3QO-6QQ1M90=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep detector
curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%auto%detector%onm80KQF8s6d2p_laW0S5IYanUUsLcnB3QO-6QQ1M90=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep p00 curl -v --silent --data "{\"SourceCredentials\":\"processed%c20180508-000-COM20181%%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep detector
curl -v --silent --data "{\"SourceCredentials\":\"processed%c20180508-000-COM20181%auto%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep p00
curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%bla","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 401 curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%bla","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 401
token=dccMd3NT89i32Whz7yD4VQhmEJy6Kxc35wsBbWJLXp0= #token for 11000015 token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMTNxYnZqaXB0MzR0cTNtMGM5ZyIsInN1YiI6ImJ0XzExMDAwMDE1IiwiRXh0cmFDbGFpbXMiOnsiQWNjZXNzVHlwZSI6InJlYWQifX0.oiweTX_mHIRHkX7_jfOJfHM8lncapROfdQlD7cR7_84 #token for 11000015
#beamtine not online #beamtine not online
curl -v --silent --data '{"SourceCredentials":"raw%11000015%%detector%dccMd3NT89i32Whz7yD4VQhmEJy6Kxc35wsBbWJLXp0=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 401 curl -v --silent --data "{\"SourceCredentials\":\"raw%11000015%%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 401
token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMTNxYzNqaXB0MzR0cjlyOWhiZyIsInN1YiI6ImJ0XzExMDAwMDE2IiwiRXh0cmFDbGFpbXMiOnsiQWNjZXNzVHlwZSI6InJlYWQifX0.2UxFNyI9rNwX9H0ErPNjJxZBy9WEv7CYq1N1d-93Jmg #token for 11000016
curl -v --silent --data "{\"SourceCredentials\":\"raw%11000016%%detector%${token}\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 401
token=Jaas_xTpkB0Zy5dFwjs4kCrY7yXMfbnW8Ca1aYhyKBs= #token for 11000016 token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMTNxcmFyaXB0MzVjcWpuMmUxZyIsInN1YiI6ImJsX3AwNyIsIkV4dHJhQ2xhaW1zIjp7IkFjY2Vzc1R5cGUiOiJyZWFkIn19.KQFj3hOJRpc7hPqwJyYmnQ31IrR1zSz4EifUuulmP5E # for beamlne p07
curl -v --silent --data '{"SourceCredentials":"raw%11000016%%detector%Jaas_xTpkB0Zy5dFwjs4kCrY7yXMfbnW8Ca1aYhyKBs=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 401 curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 11111111
curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:5007\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 11111111
curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:5007\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep p07
curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:5007\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep /asap3/petra3/gpfs/p07/2020/data/11111111
#read access
curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep read
token=-pZmisCNjAbjT2gFBKs3OB2kNOU79SNsfHud0bV8gS4= # for bl_p07 #write access
curl -v --silent --data '{"SourceCredentials":"processed%auto%p07%detector%-pZmisCNjAbjT2gFBKs3OB2kNOU79SNsfHud0bV8gS4=","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 11111111 token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMTNxcmFyaXB0MzVjcWpuMmUxZyIsInN1YiI6ImJsX3AwNyIsIkV4dHJhQ2xhaW1zIjp7IkFjY2Vzc1R5cGUiOiJyZWFkIn19.KQFj3hOJRpc7hPqwJyYmnQ31IrR1zSz4EifUuulmP5E # for beamlne p07, write access
curl -v --silent --data '{"SourceCredentials":"raw%auto%p07%detector%-pZmisCNjAbjT2gFBKs3OB2kNOU79SNsfHud0bV8gS4=","OriginHost":"127.0.0.1:5007"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep 11111111 curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep write
curl -v --silent --data '{"SourceCredentials":"raw%auto%p07%detector%-pZmisCNjAbjT2gFBKs3OB2kNOU79SNsfHud0bV8gS4=","OriginHost":"127.0.0.1:5007"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep p07
curl -v --silent --data '{"SourceCredentials":"raw%auto%p07%detector%-pZmisCNjAbjT2gFBKs3OB2kNOU79SNsfHud0bV8gS4=","OriginHost":"127.0.0.1:5007"}' 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr | grep /asap3/petra3/gpfs/p07/2020/data/11111111
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment