标签: http-post

如何防止POST方法被黑客攻击

我有一个使用 $_POST 变量存储到数据库的脚本。

有些用户试图通过制作自己的 post 表单方法或使用curl 将 post 变量和值发送到服务器来欺骗系统。

我怎样才能防止这种攻击?

谢谢

php xss http-post

3
推荐指数
1
解决办法
1万
查看次数

仅使用 php 中的 http_build_query 进行 POST 请求

我需要使用http_build_query创建POST请求。以下是我的代码:

$uri_args = array (
  'name'         => 'Jack',
  'surname'      => 'Jackson',
  'username'     => 'jackson12',
  'email'        => 'Jack@mail.com',
);

$uri = http_build_query($uri_args);

header("Location: http://samplesite.com?$uri");
Run Code Online (Sandbox Code Playgroud)

目前它会生成一个类似 GET 的请求,但我需要 POST。考虑到我不想使用curl,...只使用http_build_query。

php post http-post

3
推荐指数
1
解决办法
1万
查看次数

PHPcurl,特殊的网络接口

我有一个带有两个网络接口的(网络服务器)服务器。第一个是与公共互联网连接的标准接口,另一个是虚拟 VPN 网络接口。

现在我想通过 VPN 网络内的其他 Web 服务上的curl 发送 POST 数据。

我怎么能说那里的 php 必须使用 VPN 网络接口调用该地址呢?

php vpn networking curl http-post

3
推荐指数
1
解决办法
3212
查看次数

验证 Shopify webhook

我相信要将 Shopify webhook 与 Rails 应用程序集成,Rails 应用程序需要禁用默认verify_authenticity_token方法,并使用标头实现自己的身份验证X_SHOPIFY_HMAC_SHA256。Shopify 文档说只使用request.body.read. 所以,我这样做了:

def create
    verify_webhook(request)

    # Send back a 200 OK response
    head :ok
end

def verify_webhook(request)
    header_hmac = request.headers["HTTP_X_SHOPIFY_HMAC_SHA256"]
    digest = OpenSSL::Digest.new("sha256")
    request.body.rewind
    calculated_hmac = Base64.encode64(OpenSSL::HMAC.digest(digest, SHARED_SECRET, request.body.read)).strip

    puts "header hmac: #{header_hmac}"
    puts "calculated hmac: #{calculated_hmac}"

    puts "Verified:#{ActiveSupport::SecurityUtils.secure_compare(calculated_hmac, header_hmac)}"
end
Run Code Online (Sandbox Code Playgroud)

Shopify Webhook 定向到正确的 URL,并且路由将其提供给上面显示的控制器方法。但是当我发送测试通知时,输出不正确。两个HMAC不相等,因此未验证。我相当确定问题在于 Shopify 使用整个请求作为身份验证哈希的种子,而不仅仅是 POST 内容。所以,我需要原始的、未受影响的 HTTP 请求,除非我弄错了。

经过至少一个小时的搜索后,这个问题似乎是互联网上唯一有希望的问题。这正是我要问的,并且得到了 30 票赞成的接受答案。但他的回答……很荒谬。它吐出各种难以理解的、乱码的东西。我错过了一些明显的东西吗?

此外,这篇文章似乎表明我正在寻找的东西是不可能的。似乎 Rails 从未收到过纯粹的请求,但在到达 Rails 之前,Rack …

ruby-on-rails http http-post webhooks shopify

3
推荐指数
1
解决办法
2488
查看次数

Angular 6 htttp POST - 将参数设置为 URL 中的查询字符串

我有一个基于 asp .net core 样板的应用程序。我需要从我的 Angular 6 应用程序发送 http POST 参数。

我的服务如下所示:

public findProduct(productCode: string) {
const url_ = 'api/product/findProduct';
const params = new URLSearchParams();
params.set('productCode', productCode);

return this.http.post(url_, params, httpHeaders)
  .subscribe(
    result => {
      console.log(result);
    },
    error => {
      console.log('There was an error: ')
    }
  );
Run Code Online (Sandbox Code Playgroud)

我已经从 @angular/http 导入了 URLSearchParams,但仍然遇到同样的问题。我的 POST URL 很糟糕,因为 API 期望 POST URL 如下所示: http://localhost:21021/api/product/findProduct?productCode=1111并查询字符串参数,如: productCode: 1111

但我的看起来像这样: http://localhost:21021/api/product/findProduct 并设置请求负载(始终为空):

**{rawParams: "", queryEncoder: {}, paramsMap: {}}
paramsMap: {}
queryEncoder: {}
rawParams: ""**
Run Code Online (Sandbox Code Playgroud)

我的 httpHeaders …

http-post angular angular6

3
推荐指数
1
解决办法
1万
查看次数

获取发送到 Python/Django 的 POST 请求(通过 Axios 库)的 None 值

我正在使用 Django/Python 构建一个 Web 应用程序,并尝试使用 Axios 库(在 Vue.js 代码中)通过 POST 请求将数据发送到控制器。

POST QueryDict 似乎是空的,我不明白为什么会发生这种情况:

changeCountry: function(e, id){
  console.log("Let's change the country")
  console.log(e.target.value) // is printing correctly
  console.log(id) // also printing correctly

  axios({
    method: 'post',
    url: '/template/country',
    data: {
      id: id,
      country: e.target.value
    },
    headers: {
      'X-CSRFToken': "{{csrf_token}}"
      }
    })
    .then(function (response) {
      alert(response.data); // this is returning what I expect
    })
    .catch(function (error) {
      console.log(error);
    })
  },
Run Code Online (Sandbox Code Playgroud)

Python 方法如下所示:

def update_template_country(request):

  pprint(request.POST) # prints an empty QueryDict

  id = request.POST.get('id') …
Run Code Online (Sandbox Code Playgroud)

javascript python django http-post axios

3
推荐指数
1
解决办法
1910
查看次数

使用 POST 方法将文件上传到 file.io

我在 SO 找到了一个链接,该链接可能会对此查询产生影响 将图片上传到 VBA 中的 file.io (HTTP Post) 这个链接中的代码

Sub UploadFilesUsingVBAORIGINAL()
     'this proc will upload below files to https://file.io/
          '  png, jpg, txt

        Dim fileFullPath As String
        fileFullPath = ThisWorkbook.Path & "\Sample.txt"

        POST_multipart_form_dataO fileFullPath
    End Sub

Private Function GetGUID() As String
    ' Generate uuid version 4 using VBA
    GetGUID = WorksheetFunction.Concat(WorksheetFunction.Dec2Hex(WorksheetFunction.RandBetween(0, 4294967295#), 8), "-", WorksheetFunction.Dec2Hex(WorksheetFunction.RandBetween(0, 65535), 4), "-", WorksheetFunction.Dec2Hex(WorksheetFunction.RandBetween(16384, 20479), 4), "-", WorksheetFunction.Dec2Hex(WorksheetFunction.RandBetween(32768, 49151), 4), "-", WorksheetFunction.Dec2Hex(WorksheetFunction.RandBetween(0, 65535), 4), WorksheetFunction.Dec2Hex(WorksheetFunction.RandBetween(0, 4294967295#), 8))

End Function

Private Function GetFileSize(fileFullPath As String) …
Run Code Online (Sandbox Code Playgroud)

excel vba http-post

3
推荐指数
1
解决办法
3134
查看次数

从 Angular 8 并行处理多个 API 请求

我需要从我的角度应用程序并行调用多个 API 请求,并且需要分别获取每个响应(需要为每个响应执行一些不同的操作),并且我还需要跟踪所有请求何时完成执行

例如我有一个请求数组arr1[request1,request2,request3,request4],每个请求将花费不同的时间来获得响应。所以我需要根据响应执行不同的操作,如actn1,actn2,actn3 ..等.我需要以 FCFS 方式调用每个操作。某些请求将比其他请求更快地完成执行,因此每当我收到每个请求的响应时,我需要调用相应的操作,最后在获得所有响应后我还需要调用 FinalAction。

通过使用 forkJoin 我能够执行我的 FinalAction(在完成所有请求执行后,这必须起作用),但我不知道每当响应来自服务器时我将如何执行每个响应操作

http-post rxjs angular

3
推荐指数
1
解决办法
9736
查看次数

将额外数据附加到 Django 中的 request.POST

我正在 Django 中开发 PDF 显示功能,用户以 HTML 形式输入数据,然后可以单击按钮Preview查看 PDF 格式的预览。

这些是我的views.py 中的行,它们返回 pdf 作为响应:

pdf = render_to_pdf('new_pdf.html', params)
return HttpResponse(pdf, content_type='application/pdf')
Run Code Online (Sandbox Code Playgroud)

这里render_to_pdf()使用 HTML 模板和普通的 Python 字典将数据嵌入 HTML 页面并将其转换为 PDF。

我目前正在将表单 POST 数据作为参数传递,即 params = {'data':request.POST}

request.POST 看起来像这样

<QueryDict: {'csrfmiddlewaretoken': ['some_random_string_here'], 'client_id': ['26'], 'note_no': ['5']}>
Run Code Online (Sandbox Code Playgroud)

还有一些其他领域...

现在我可以简单地{{data.client_id}}在 HTML 中使用来获取数据。

到目前为止一切正常

但我需要向我的参数提供一些额外的数据以显示在 PDF 上。

我想知道是否有一种方法可以附加我的额外request.POST变量

request.POST['credit_type'] = [credit_type]
Run Code Online (Sandbox Code Playgroud)

但这不是一个常规的 python 字典,并且给出了 This QueryDict instance is immutable.

有什么解决方法吗?

或者我是否必须使用常规方法将键值对附加到我的params然后使用它们?

django http-post django-templates

3
推荐指数
1
解决办法
8084
查看次数

Spring Boot REST API POST 401 未经授权

这真的很奇怪,我确信我错过了一些东西。这是我的 spring 安全配置类:

@Configuration
@EnableWebSecurity
public class AppSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private DataSource dataSource;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {

        auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(passwordEncoder())
                .usersByUsernameQuery(
                        "select username,password, enabled from user where username=?")
                .authoritiesByUsernameQuery(
                        "select username, authority from authorities where username=?");

    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http    .cors()
                .and()
                .authorizeRequests() // authorize
                .antMatchers("/task/*").permitAll()
                .antMatchers(HttpMethod.POST,"/task/*").permitAll()
                .anyRequest().authenticated() // all requests are authenticated
                .and()
                .httpBasic();
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

}

Run Code Online (Sandbox Code Playgroud)

因此,在Postman上,当我发送GET …

java spring http-post spring-security spring-boot

3
推荐指数
1
解决办法
9341
查看次数