token-validator: add missing SSH challenge

This commit is contained in:
nemunaire 2020-02-27 15:30:07 +01:00
parent 7bac1ead6b
commit 0302d30390

View File

@ -30,6 +30,10 @@ func noAccessRestriction(*Student, *http.Request) error {
return nil return nil
} }
func noAccess(*Student, *http.Request) error {
return errors.New("This challenge cannot be accessed this way. ")
}
func accessFrom(ip string) func(_ *Student, r *http.Request) error { func accessFrom(ip string) func(_ *Student, r *http.Request) error {
return func(_ *Student, r *http.Request) error { return func(_ *Student, r *http.Request) error {
if r.Header.Get("X-Forwarded-By") != ip { if r.Header.Get("X-Forwarded-By") != ip {
@ -243,6 +247,9 @@ func init() {
}, },
/* Last : SSH key, see ssh.go:156 in NewKey function */ /* Last : SSH key, see ssh.go:156 in NewKey function */
Challenge{
Accessible: []func(*Student, *http.Request) error{noAccess},
},
} }
router.GET("/challenges", apiHandler(getChallengeList)) router.GET("/challenges", apiHandler(getChallengeList))