标签: basic-authentication

如何使用JMeter传递随机用户/通行证(用于基本身份验证)?

我正在使用JMeter来压力测试API.我已经Basic Authentication成立了 - 似乎工作得很好.

现在,我正在尝试随机化 JMeter通过网络传递的凭据.所以,有两种方法我知道我可以做到这一点.

  1. 添加一个自定义HTTP Header(通过一个HTTP Header Manager Element)并将then值设置为随机字段(即我从csv文件中读取的内容)
  2. 使用HTTP Authorization Manager Element并传递用户名和密码.

现在,如果我尝试使用上面的方法(1),我需要创建以下标头/数据: -

Authorization: Basic <some Base64 encoded string in the format username:password>

eg.
Authorization: Basic OnVzZXIxOnBhc3Mx
Run Code Online (Sandbox Code Playgroud)

KEWL.简单.但是标题值没有通过电线传递:(我可以添加任何其他标头类型,它通过电线传递..

嗯..好吧然后..让我们尝试方法(2).

现在可行..但我只能用用户名和密码进行硬编码.我无法看到我如何传递用户名VARIABLE(即.${usernmae})或密码VARIABLE(即.${password})....如果它是硬编码的,那么服务器正确回复正确的页面/数据.

所以..有人可以帮忙吗?

jmeter basic-authentication

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

嵌入式Jetty 7服务器的基本身份验证,没有web.xml文件

我有一个作为服务运行的Jetty 7的嵌入式实现,并且想要为servlet添加没有web.xml文件的基本身份验证.

我使用此处描述的步骤创建了我的凭据

我以为我可以创建服务器,使用基本身份验证创建安全处理程序并将HashLoginService附加到安全管理器.但我显然遗漏了几件事,因为我从来没有得到凭证的提示.

下面是代码.任何帮助将不胜感激.

    server = new Server(port);
    server.addConnector(getSslChannelConnector(securePort));
    server.setGracefulShutdown(1000);
    server.setStopAtShutdown(true);

    // create the context handler for the server
    ServletContextHandler sch = new ServletContextHandler(server, WEBAPP_CONTEXT);

    // attach the security handler to it that has basic authentication
    sch.setSecurityHandler(getSecurityHandler());

    // define the processing servlet.
    sch.addServlet(new ServletHolder(new ProcessingServlet()), "/process");

    .
    .
private SecurityHandler getSecurityHandler() {

    // add authentication
    Constraint constraint = new Constraint(Constraint.__BASIC_AUTH,"user");
    constraint.setAuthenticate(true);
    constraint.setRoles(new String[]{"user","admin"});

    // map the security constraint to the root path.
    ConstraintMapping cm = new ConstraintMapping(); …
Run Code Online (Sandbox Code Playgroud)

jetty basic-authentication

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

使用HTML5音频播放安全音频流

是否可以使用HTML5音频标签播放受保护的流?我正在播放的流受密码保护(HTTP基本身份验证),我如何提供凭据?提前致谢

basic-authentication html5-audio

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

通过CXF拦截器的HTTP基本身份验证不起作用

我在使用Apache CXF为Web服务请求设置HTTP Authorization标头时遇到了一些麻烦.我在春天有我的客户端设置:

<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />

<bean id="myHTTPAuthInterceptor" class="my.app.MyHTTPAuthInterceptor" autowire="constructor" />

<bean id="webServiceFactory" class="my.app.WebServiceFactory">
    <property name="wsdlLocation" value="classpath:/my/app/webservice.wsdl" />
    <property name="serviceURL">
        <jee:jndi-lookup jndi-name="webservice/url" />
    </property>
    <property name="inInterceptors">
        <list>
            <ref bean="loggingInInterceptor" />
        </list>
    </property>
    <property name="outInterceptors">
        <list>
            <ref bean="loggingOutInterceptor" />
            <ref bean="myHTTPAuthInterceptor" />
        </list>
    </property>
</bean>

<bean id="myWebService" factory-bean="webServiceFactory" factory-method="getInstance" />
Run Code Online (Sandbox Code Playgroud)

标头是通过MyHTTPAuthInterceptor设置的,如下所示:

public MyHTTPAuthInterceptor(ConfigDao configDao)
{
    super(Phase.POST_PROTOCOL);

    this.configDao = configDao;
}

@Override
public void handleMessage(Message message) throws Fault
{
    Map<String, List<?>> headers = (Map<String, List<?>>) message.get(Message.PROTOCOL_HEADERS);

    String …
Run Code Online (Sandbox Code Playgroud)

java web-services cxf basic-authentication

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

如何使用.Net Windows服务的新基本身份验证对Visual Studio Team Services进行身份验证?

我试图从我在.NET上编写的Windows服务访问https://visualstudio.com(以前称为https://tfs.visualstudio.com,http://www.tfspreview.com).

我想使用新的基本身份验证,但我找不到办法.

我发现很多链接到博客帖子Team Foundation Service更新 - 8月27日,但它正在使用Team Explorer Everywhere Java客户端进行TFS.

是否有新版本的TFS .NET对象模型支持基本身份验证?

顺便说一下,我已经连续登录了服务帐户.这个答案非常有用.

.net c# tfs basic-authentication azure-devops

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

Nginx反向代理 - 直通基本身份验证

我正在尝试将nginx设置为使用基本身份验证进行身份验证的几个IIS Web服务器之前的反向rpoxy服务器.

(注意 - 这与使用密码文件提供auth的nginx不同 - 它应该只是在浏览器/服务器之间进行marshelling everythnig)

它的工作类型 - 但在页面上的每个资源(图像/ css等)反复提示auth.

upstream my_iis_server {
      server 192.168.1.10;
}

server {
    listen       1.1.1.1:80;
    server_name  www.example.com;  

    ## send request back to my iis server ##
    location / {
     proxy_pass  http://my_iis_server;
     proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
     proxy_http_version      1.1;
     proxy_set_header        Connection "";
     proxy_pass_header       Authorization;     
     proxy_redirect off;
     proxy_buffering off;
     proxy_set_header        Host            $host;
     proxy_set_header        X-Real-IP       $remote_addr;
     proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
   }
}
Run Code Online (Sandbox Code Playgroud)

iis reverse-proxy nginx basic-authentication

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

在nginx后面使用GitLab启用basic_auth?

我已经成功安装了GitLab来管理私有存储库(它非常棒!).

我遇到的问题是默认情况下,当有人点击我的子域时会出现Gitlab登录.在用户获取GitLab登录屏幕之前,我想用basic_auth层保护整个区域.不幸的是,当它启用时,这会破坏我从GitLab推/拉的能力.

我的nginx配置启用basic_auth:

  auth_basic            "Restricted";
  auth_basic_user_file  htpasswd;
Run Code Online (Sandbox Code Playgroud)

关于如何在不破坏git/gitlab功能的情况下启用basic_auth的任何想法?

nginx basic-authentication gitlab

8
推荐指数
2
解决办法
4885
查看次数

如何使ServiceStack身份验证工作?(使用iPhone客户端)

我们聘请了一位为我们编写iPhone应用程序的承包商,我开始用ServiceStack为它编写后端服务.

我一般都在努力获得授权:使用何种授权以及如何实施授权.
我对ServiceStack,HTTP和授权(我)了解不多.我读过这篇文章,但我可能还是做错了.

我将使用现有遗留数据库中的用户名和密码进行身份验证(但没有别的 - 没有注册新用户,没有不同的权限.只是进行身份验证).
所以我需要编写自己的提供者.

我已经设法在本教程CredentialsAuthProvider的帮助下实现了一个工作. 它在我在浏览器中测试时有效:

  • 拨打我的服务并获得401
  • 发布到 auth/credentials
  • 再次呼叫我的服务并获得正确的结果

但是,我注意到当我在Fiddler中尝试时,相同的工作流程不起作用.

POST auth/credentials工作.我发布这个:

POST http://localhost:52690/auth/credentials?format=json HTTP/1.1
User-Agent: Fiddler
Host: localhost:52690
Content-Length: 74
Content-Type: application/json; charset=utf-8

{
  "UserName": "chspe",
  "Password": "xyz",
  "RememberMe": true
}
Run Code Online (Sandbox Code Playgroud)

......得到这个:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Fri, 14 Jun 2013 13:07:35 GMT
X-AspNet-Version: 4.0.30319
X-Powered-By: ServiceStack/3,949 Win32NT/.NET
Set-Cookie: ss-id=3YUUgfwIeJd7PedFK5Th; path=/; HttpOnly
Set-Cookie: ss-pid=zQJ5Z4Vq7AY+BpVwbttj; expires=Tue, 14-Jun-2033 13:07:35 GMT; path=/; HttpOnly
Set-Cookie: ss-opt=perm; expires=Tue, 14-Jun-2033 13:07:35 GMT; …
Run Code Online (Sandbox Code Playgroud)

c# authentication web-services basic-authentication servicestack

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

如何将HTTP Basic Auth作为Sonatype Nexus URL的一部分用于工件下载?

我可以使用HTTP标头中的HTTP基本身份验证凭据从Sonatype Nexus下载该文件.

但是我无法通过将凭据作为URL的一部分来实现这一点 - 这样的事情:

http://admin:admin123@nexus.example.com/nexus/service/local/artifact/maven/content?g=com.test&a=project&v=1.0&r=test_repo_1_release
Run Code Online (Sandbox Code Playgroud)

有没有人知道为什么或如何在标题中不使用auth来实现相同的目的?

PS:这是一个测试环境 - 因此没有SSL.

nexus basic-authentication

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

Yii 2 RESTful API使用HTTP Basic进行身份验证(Yii 2高级模板)

REST API无需身份验证方法即可运行.现在,我想通过移动应用程序对API请求进行HTTP基本身份验证来验证REST API.我试过yii2指南,但它对我不起作用.

基本上移动用户需要使用用户名和密码登录,如果用户名和密码正确,则用户需要登录,并且需要使用令牌进一步验证API请求.

当我调试findIdentityByAccessToken()函数时,$ token等于用户名.Postman扩展用于检查HTTP Basic请求.用户表中的access_token字段为空.我需要手动保存吗?如何将access_token作为响应返回?

这三种方法(HttpBasicAuth,HttpBearerAuth,QueryParamAuth)是否有任何原因,为什么?怎么样?

我的应用程序文件夹结构如下所示.

api
-config
-modules
--v1
---controllers
---models
-runtime
-tests
-web

backend
common
console
environments
frontend
Run Code Online (Sandbox Code Playgroud)

API \模块\ V1\Module.php

namespace api\modules\v1;
class Module extends \yii\base\Module
{
    public $controllerNamespace = 'api\modules\v1\controllers';

    public function init()
    {
        parent::init(); 
        \Yii::$app->user->enableSession = false;       
    }   
}
Run Code Online (Sandbox Code Playgroud)

API \模块\ V1 \控制器\ CountryController.php

namespace api\modules\v1\controllers;
use Yii;
use yii\rest\ActiveController;
use common\models\LoginForm;
use common\models\User;
use yii\filters\auth\CompositeAuth;
use yii\filters\auth\HttpBasicAuth;
use yii\filters\auth\HttpBearerAuth;
use yii\filters\auth\QueryParamAuth;

class CountryController extends ActiveController
{
    public $modelClass = 'api\modules\v1\models\Country';    

    public …
Run Code Online (Sandbox Code Playgroud)

api rest basic-authentication yii2 yii2-advanced-app

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