Example #1
0
func ReqToken(req *http.Request, success func(string) fhttp.Response) fhttp.Response {
	token := oauth2.DecodeToken(req)
	if token == nil {
		return fhttp.UserError("invalid_token")
	}
	return success(token.User)
}
Example #2
0
func ReqTrustedClient(req *http.Request, success func(string) fhttp.Response) fhttp.Response {
	config, err := conf.ReadConfigFile("config.ini")
	if err != nil {
		panic(err)
	}
	clientId, err := config.GetString("webclient", "clientId")
	if err != nil {
		panic(err)
	}
	token := oauth2.DecodeToken(req)
	if token == nil || token.Client != clientId {
		return fhttp.UserError("invalid_token")
	}
	return success(token.User)
}