标签: http-status-code-401

IIS7 中的 ApplicationPoolIdentity 401 错误

我们刚刚开始使用 Windows Server 2008 R2 和 IIS7.5,我正在尝试将一些现有站点从 Windows 2003 环境中移出。我可以让网站正常运行,但网站中的所有 CSS/图像均出现 401 错误。授予每个人读取权限将解决这个问题 - 但我不太高兴这样做。

我读到,IIS7.5 使用了一个神奇的新“帐户”,每个应用程序池都有自己的帐户。

到目前为止我已经

  • 在 wwwroot 中为我的网站 (kbank) 创建了一个新文件夹
  • 从另一台机器复制文件
  • 在IIS7中创建了一个新网站(不是虚拟目录),这创建了一个与我的网站同名的新应用程序池。这是一个综合管道池
  • 在流程模型/身份中,这是使用 ApplicationPoolIdentity 并将“加载用户配置文件”设置为 True
  • 授予 IIS AppPool\kbank 对文件夹根目录的读取权限

谁能告诉我如何最好地设置我的网站。

iis-7 iis-7.5 http-status-code-401

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

自定义 401 页面不提示输入 nginx 上的凭据

我的网站的一部分受到以下保护auth_basic

    location / {
            auth_basic "Authorization Required";
            auth_basic_user_file .htpasswd;
            index  app.php;
            try_files $uri @rewriteapp;
    }
Run Code Online (Sandbox Code Playgroud)

对于未经授权的用户(单击“取消”的用户),我想显示自定义错误页面。我是这样做的:

    error_page 401 = @error401;

    location @error401 {
                    rewrite ^ /error/401.html redirect;
    }

    location /error {
            expires max;
            add_header Pragma public;
            add_header Cache-Control "public";
            index  app.php;
            try_files $uri @rewriteapp;
    }
Run Code Online (Sandbox Code Playgroud)

我必须创建 @error401 别名,以便我可以指定“重定向”,因为如果我使用内部重定向,我的应用程序将处理原始请求(并提供对实际请求页面的访问权限!)

所以这工作正常,页面显示。问题是现在 nginx 甚至不要求用户提供凭据。

有没有什么办法解决这一问题 ?或者有什么更好的方法来处理这个问题?

nginx basic-authentication http-status-code-401

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

即使我启用匿名身份验证,调用 Web api 时也会出现 401 Unauthorized

我正在开发一个网络 API。当我通过 Visual Studio 在本地工作站中运行 Web api 并使用 Fiddler 或 IE 来使用它时,一切都很好。
但是,如果我将其部署到远程 IIS 服务器中,我会在 IE、Fiddler 或客户端应用程序中收到 401 错误代码。即使我在 IIS 中启用匿名身份验证,401 仍然出现。
有人能给我一些建议吗?
谢谢。

authentication iis http-status-code-401 asp.net-web-api

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

PHP 401 状态返回 -1

我正在尝试401在我的应用程序中返回响应状态AngularJS。但在我看到的控制台中,它返回-1

我在 php 中使用的是:

header("HTTP/1.1 401 Unauthorized");
http_response_code(401);
Run Code Online (Sandbox Code Playgroud)

也在代码点火器中:

$this->output->set_header('HTTP/1.1 401 Unauthorized');
$this->output->set_status_header(401, "my status text");
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

它在状态代码中工作良好,例如: 200 、 205 、 206 等。

在此输入图像描述

任何想法?

php codeigniter http-response-codes http-status-code-401 angularjs

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

Rotativa 使用 Windows 身份验证获取 401.2 代码状态

我有一个使用 Windows 身份验证的 MVC 5 项目。为了添加 pdf 导出支持,我​​尝试设置 Rotativa lib。第一次尝试是Controller方法

public ActionResult PrintViewToPdf()
{
    return new ActionAsPdf("myAction");
}
Run Code Online (Sandbox Code Playgroud)

这会导致 pdf 文件中出现错误 401.2 页面。据我了解(请让我知道是否有其他解决方案!!!),有唯一的解决方法:

public ActionResult PrintViewToPdf()
{
    return new ViewAsPdf("myView");
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我得到一个 pdf 文件,但它内容是一个没有完成 javascript 脚本的网页!

那么,问题是:除了替换之外还有其他解决方案ActionAsPdfViewAsPdf?如果不是,是否可以包含ViewAsPdfjavascript 执行结果?

http-status-code-401 rotativa asp.net-mvc-5

5
推荐指数
0
解决办法
477
查看次数

由于 PWA 服务工作线程缓存,身份验证基本 401 页面不会提示输入凭据

我在我的开发网站(例如 dev.example.com)上使用基本身份验证,但遇到了一个问题:我的网站在初次访问后没有提示我输入凭据。换句话说,如果我清除浏览器缓存,就会出现提示,我就可以正常登录。会话仍然存在,但在会话过期并且我自动注销后,系统不会再次提示我输入凭据。

这也意味着如果我点击“取消”,我将不会再收到提示。

刷新并不能解决问题,我在初次访问后能够查看该网站的唯一方法是每次使用隐身窗口,或者清除缓存并刷新页面。

该页面显示默认的 401 nginx 错误页面,响应是实际的 401 错误。

401 页眉

我尝试将auth_basic线路移动到配置的各个部分,但这似乎没有效果。我没有自定义 401 错误页面,因此我没有指定error_page 401,这会是一个问题吗?

我还发现了这个问题,IE、FireFox、Opera 和 Safari 在服务器连续 401 响应时不显示 BASIC 身份验证提示

其中所述是通过www-authenticate在标题上设置来解决的,但这是为我定义的。

这可能与配置有关吗?这是我当前的配置:

server {
    server_name dev.MYSITE.com;

    root /srv/dev/MYSITE/current;
    index index.php index.html index.htm;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_max_temp_file_size 0;
        proxy_pass http://localhost:3010;
        proxy_redirect off;
        proxy_read_timeout 240s;

        # Basic HTTP Auth
        auth_basic "MYSITE Dev Site";
        auth_basic_user_file /etc/nginx/sites-password/MYSITE.htpasswd;
    } …
Run Code Online (Sandbox Code Playgroud)

nginx basic-authentication offline-caching http-status-code-401 progressive-web-apps

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

OKHTTP 在 POST 请求上返回 401 错误,但它正在与 POSTMAN 一起使用

我正在使用 OKHTTP3 向我的服务器代码发出 POST 请求。它返回 401 UNAUTHORIZED 错误。然而,同样的事情也适用于 POSTMAN。POSTMAN 和我的代码之间的唯一区别可能是会话 cookie(我将其作为标头传递)。下面是我的代码

import java.io.*;
import java.net.*;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import okhttp3.*;
import org.json.JSONObject;

public class Main
{


  public static final String SESSION_URL = "http://localhost:8080/security/rest/token/access/session/0";
  public static final String CREATE_PROJECT_URL = "http://localhost:8080/managers/CDQRuntime/smartdq/training/";
  public static String PROJECT_NAME = "testproject201234";
  static String MANAGEMENT_TOKEN="YWRtaW46YWRtaW4=";
  public static void main(String[]args) throws IOException
  {
    //Get session api call
    Request request = new Request.Builder()
            .url(SESSION_URL)
            .get()
            .addHeader("Authorization", "Basic " + MANAGEMENT_TOKEN)
            .build();
    OkHttpClient client=new …
Run Code Online (Sandbox Code Playgroud)

java post session-cookies http-status-code-401 okhttp

5
推荐指数
0
解决办法
2350
查看次数

在 Postman 中完美工作时,从 Android 应用程序发送发布请求时出现 401 Auth 错误

我正在将 exotel 呼叫服务集成到我的一个客户 Android 应用程序中。Api 在邮递员中工作正常并接收 xml 响应,但它在 Android 应用程序中不起作用并给出 volley 401 身份验证错误。

val stringRequest = object : StringRequest(Request.Method.POST,
                        URL,
                        Response.Listener { response ->
                            Toast.makeText(context, "response " + response.toString(), Toast.LENGTH_SHORT).show()
                            Log.d("Callresponse", response.toString())
                        }, Response.ErrorListener { error ->
                    Log.d("Callresponseerror", error.message.toString())
                    Toast.makeText(context, "error " + error.message, Toast.LENGTH_SHORT).show()
                }) {
                    override fun getParams(): MutableMap<String, String> {
                        val params = HashMap<String, String>()
                        params["From"] = AppSetting.getSitterMobile(context, AppConstants.PREF_MOBILE, null)
                        params["To"] = contact
                        params["CallerId"] = "*****"
                        params["CallType"] = "****"
                        return params
                    }
                }
                stringRequest.retryPolicy = DefaultRetryPolicy(10,
                        10, …
Run Code Online (Sandbox Code Playgroud)

android http-post http-status-code-401 android-volley exotel-api

5
推荐指数
0
解决办法
503
查看次数

为什么我启用 csrf 时收到 401 错误?

因此,我正在开发我的第一个全栈应用程序(Spring Boot Rest API 和 Vue.js 前端),并且我在使用 sonarqube 时遇到了一个问题。我的声纳发出以下警告:

确保在这里禁用 Spring Security 的 CSRF 保护是安全的。

它来自这个文件:

@Configuration
@AllArgsConstructor
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class
WebSecurityConfig extends WebSecurityConfigurerAdapter {//provides security for endpoints

    @Autowired
    private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;

    @Autowired
    private UserDetailsService jwtUserDetailsService;

    @Autowired
    private JwtRequestFilter jwtRequestFilter;

    private final AccountService accountService;
    private final BCryptPasswordEncoder bCryptPasswordEncoder;

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        // configure AuthenticationManager so that it knows from where to load
        // user for matching credentials
        // Use BCryptPasswordEncoder
        auth.userDetailsService(jwtUserDetailsService).passwordEncoder(bCryptPasswordEncoder);
    } …
Run Code Online (Sandbox Code Playgroud)

security csrf http-status-code-401 spring-boot

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

使用Python中的OAuth的Twitter流在两个同等配置的计算机上表现不同

我有相同的编码来处理在两台不同的机器上运行的Twitter用户流.两台机器都是使用python 2.6.5的Ubuntu Lucid,但在我家的机器上,我HTTP Error 401: Unauthorized在大学时收到它完美的工作.在两台机器上,当我使用具有相同参数的curl时,它完美地工作,即消费者密钥,消费者密钥,访问令牌和访问密钥.

看下面的代码,它是由Josh Sharp创建的

from oauth.oauth import OAuthRequest, OAuthSignatureMethod_HMAC_SHA1
from hashlib import md5
import json, time
import random, math, re, urllib, urllib2

STREAM_URL = "https://userstream.twitter.com/2/user.json"

class Token(object):
    def __init__(self,key,secret):
        self.key = key
        self.secret = secret

    def _generate_nonce(self):
        random_number = ''.join(str(random.randint(0, 9)) for i in range(40))
        m = md5(str(time.time()) + str(random_number))
        return m.hexdigest() 

CONSUMER_KEY = 'consumer_key'
CONSUMER_SECRET = 'consumer_secret'
ACCESS_TOKEN = 'token'
ACCESS_TOKEN_SECRET = 'token_secret'

access_token = Token(ACCESS_TOKEN,ACCESS_TOKEN_SECRET)
consumer …
Run Code Online (Sandbox Code Playgroud)

python twitter urllib2 http-status-code-401 twitter-oauth

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