标签: http-authentication

authentication_or_request_with_http_token 从不通过

我正在尝试按照railscast 的本教程为我的 rails API 实现身份验证。我正在使用方法authenticate_or_request_with_http_token,我应该检查块内的令牌,如果块返回true,它应该通过。但是,即使我只是将 true 放入块中,该方法也永远不会通过。这是我在日志中看到的:

我正在使用导轨 4.0

  Filter chain halted as :restrict_access rendered or redirected
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

  before_filter :restrict_access

  def restrict_access
    authenticate_or_request_with_http_token do |token, options|
      true
    end
  end
Run Code Online (Sandbox Code Playgroud)

authentication http-authentication ruby-on-rails-4

2
推荐指数
1
解决办法
1076
查看次数

Http模块认证

我正在使用这篇文章中的以下代码来尝试创建一个自定义 http 模块:

public class BasicAuthenticationModule: IHttpModule
{
  public void Init(HttpApplication application)
  {
    application.AuthenticateRequest += new EventHandler(Do_Authentication);
  }

  private void Do_Authentication(object sender, EventArgs e)
  {
    var request = HttpContext.Current.Request;
    string header = request.Headers["HTTP_AUTHORIZATION"];
    if(header != null && header.StartsWith("Basic "))
    {
      // Header is good, let's check username and password
      string username = DecodeFromHeader(header, "username");
      string password = DecodeFromHeader(header, password);

      if(Validate(username, password) 
      {
        // Create a custom IPrincipal object to carry the user's identity
        HttpContext.Current.User = new BasicPrincipal(username);
      } …
Run Code Online (Sandbox Code Playgroud)

c# httpmodule http-authentication

2
推荐指数
1
解决办法
9899
查看次数

迅捷3-WKWebView中的HTTP身份验证

我正在尝试构建一个显示网页的简单WebView-该页面要求所有页面都使用http身份验证(出于测试目的)。

这是我的代码:

class ViewController: UIViewController, WKUIDelegate {

    var webView: WKWebView!

    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView
    }

    // #1 variant
    func webView(webView: WKWebView, willSendRequestForAuthenticationChallenge challenge:
        URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
        let user = "user"
        let password = "pass"
        let credential = URLCredential(user: user, password: password, persistence: URLCredential.Persistence.forSession)
        challenge.sender?.use(credential, for: challenge)
    }

    // #2 variant
    func webView(webView: WKWebView, didReceiveAuthenticationChallenge challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> …
Run Code Online (Sandbox Code Playgroud)

http-authentication swift wkwebview swift3

2
推荐指数
1
解决办法
4825
查看次数

更改基本HTTP身份验证领域和登录对话框消息

我想更改在实施基本身份验证期间弹出的消息。当前的默认消息是:

在此处输入图片说明

服务器需要用户名和密码。

对我来说更准确的是:

服务器需要电子邮件和密码。

我的问题是我找不到或不知道此消息在哪里设置以及是否可以更改。在线上的大多数问题都与基本身份验证实现有关,但这不是我的问题-我可以很好地实现它。我只需要为用户提供更准确的答复。

这是我使用echo强制验证窗口的方式:

c.Response().Header().Set(echo.HeaderWWWAuthenticate, `Basic realm="Your Email is your Username"`)
return echo.ErrUnauthorized
Run Code Online (Sandbox Code Playgroud)

注意:只有Firefox显示领域消息。Chrome和Opera都没有。

http http-authentication go http-headers

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

使用Delphi从网站获取JSON数据

有这个网站http://www.ingress.com/intel

要访问该网站,我们必须使用用户名和密码登录.

访问后,该站点使用JSON作为其数据.

我是JSON的新手.

任何人都可以举例说明如何使用Delphi从网站获取JSON数据?

我顺便使用Delphi 7.

谢谢.

delphi json http delphi-7 http-authentication

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

如何设计多字段的javascript提示框

据我从我的研究中可以看出,您无法使用可以从 JavaScript 调用的任何内置方法来创建多字段提示对话框。那么大多数路由器(192.168.0.1)的主页是如何开发认证提示框的,如下图?

我做了更多研究,发现您可以使用 php 设置基本的 http 身份验证

$user = 'user';
$password = 'pass';
if (!($_SERVER['PHP_AUTH_USER'] == $user && $_SERVER['PHP_AUTH_PW'] == $password)) {
    header('WWW-Authenticate: Basic realm="Please enter username and password to access this website"');
    header('HTTP/1.0 401 Unauthorized');
    echo '<h1>Unauthorized Access</h1>';
    exit;
}
echo "normal website contents";
Run Code Online (Sandbox Code Playgroud)

1

html javascript php http-authentication

0
推荐指数
1
解决办法
1417
查看次数

Firebase CronJobs-如何允许来自一个cronjob网站的HTTP触发器

由于Firebase(实时数据库)不支持cron-jobs,因此我正在使用cron-job.org来安排http触发器。该功能应该在每天结束时触发一次,因此大约在晚上11:55。问题是我只希望cron-job.org能够触发http端点,而没有其他人(例如,某人一天多次尝试试图触发它)。如何在云功能中实现这一目标?

我已经设置了cronjob,这就是我现在拥有的所有代码:

exports.findAndDeleteSevenDayJobs = functions.https.onRequest((req, res) => {
  console.log('req',req);
});
Run Code Online (Sandbox Code Playgroud)

另外,cron-job.org提供了以下功能:

在此处输入图片说明

而且我不知道如何使用它。

cron http-authentication firebase google-cloud-functions

0
推荐指数
1
解决办法
472
查看次数

什么是 NTLM/身份验证/协商 Web 身份验证

我了解基本和摘要身份验证。但是我已经搜索了很多,并且在 NTLM、身份验证和协商方面遇到了困难。

我认为,如果我错了,请纠正我,NTLM 和身份验证是同一协议的两个术语。

协商首先尝试 NTLM,然后回退到消化,然后回退到基本连接。

那是对的吗?如果是这样,哪里有一个很好的例子,说明如何在 C# 中连接仅用于 NTLM 和协商。

我有两个用例。首先是我需要拉下一个文件。所以发出一个请求,得到一个 XML 文件作为响应,读下来,完成。

第二个是查询 OData 成百上千个 Web 请求,每个请求都将提供 JSON(或 XML)作为响应。

c# ntlm httpwebrequest http-authentication http-negotiate

0
推荐指数
1
解决办法
3026
查看次数