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

auth error on missing access types

parent efac66e3
No related branches found
No related tags found
No related merge requests found
......@@ -161,6 +161,10 @@ func checkToken(token string, subject_expect string) (accessTypes []string, err
return nil,err
}
if extra_claim.AccessTypes==nil || len(extra_claim.AccessTypes)==0 {
return nil,errors.New("missing access types")
}
if subject!=subject_expect {
return nil,errors.New("wrong token for "+subject_expect)
}
......
......@@ -180,6 +180,10 @@ var authTests = [] struct {
message string
answer string
}{
{"processed","test","auto","dataSource", prepareUserToken("bt_test",nil),"127.0.0.2",http.StatusUnauthorized,"missing access types",
""},
{"processed","test","auto","dataSource", prepareUserToken("bt_test",[]string{}),"127.0.0.2",http.StatusUnauthorized,"empty access types",
""},
{"processed","test","auto","dataSource", prepareUserToken("bt_test",[]string{"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","access-types":["write"]}`},
{"processed","test_online","auto","dataSource", prepareUserToken("bt_test_online",[]string{"read"}),"127.0.0.1",http.StatusOK,"with online path, processed type",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment