问题列表 - 第279839页

无法使用 Postgres 数据库配置 hashcorp-vault

我想使用 hashcorp-vault 动态生成 postgres 凭证/令牌。为此,我指的是https://www.vaultproject.io/docs/secrets/databases/postgresql.html

这是配置插件的命令:

vault write database/config/my-postgresql-database \
    plugin_name=postgresql-database-plugin \
    allowed_roles="my-role" \
    connection_url="postgresql://{{username}}:{{password}}@localhost:5432/" \ 
    username="root" \
    password="root"
Run Code Online (Sandbox Code Playgroud)

但是抛出以下错误

* error creating database object: error verifying connection: pq: SSL is not enabled on the server
Run Code Online (Sandbox Code Playgroud)

你们能帮我解决这个错误吗?

注意:我的是开发服务器,因此未启用 SSL。我不知道如何启用它。

postgresql hashicorp-vault

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

如何在 MockRestServiceServer 中通过字符串模式期望 requestTo?

我有以下测试:

org.springframework.test.web.client.MockRestServiceServer mockServer
Run Code Online (Sandbox Code Playgroud)

当我使用any(String.class)或确切的 URL运行时,它们运行良好:

mockServer.expect(requestTo(any(String.class)))
.andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("response", MediaType.APPLICATION_JSON));
Run Code Online (Sandbox Code Playgroud)

或者:

mockServer.expect(requestTo("https://exact-example-url.com/path"))
.andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("response", MediaType.APPLICATION_JSON));
Run Code Online (Sandbox Code Playgroud)

我希望通过字符串模式请求避免检查确切的 URL。我可以在Spring MockRestServiceServer上编写自定义匹配器来处理对同一 URI 的多个请求(自动发现)

有没有其他方法可以mockServer.expect(requestTo(".*example.*"))通过 String 模式制作?

java junit mockito spring-boot mockserver

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

如何在Python中创建从Pub / Sub到GCS的数据流管道

我想使用Dataflow将数据从发布/订阅移到GCS。因此,基本上我希望Dataflow在固定的时间量(例如15分钟)中累积一些消息,然后在经过该时间量后将这些数据作为文本文件写入GCS。

我的最终目标是创建一个自定义管道,因此“ Pub / Sub to Cloud Storage”模板对我来说还不够,而且我完全不了解Java,这使我开始使用Python进行调整。

这是到目前为止我所获得的(Apache Beam Python SDK 2.10.0):

import apache_beam as beam

TOPIC_PATH="projects/<my-project>/topics/<my-topic>"

def CombineFn(e):
    return "\n".join(e)

o = beam.options.pipeline_options.PipelineOptions()
p = beam.Pipeline(options=o)
data = ( p | "Read From Pub/Sub" >> beam.io.ReadFromPubSub(topic=TOPIC_PATH)
       | "Window" >> beam.WindowInto(beam.window.FixedWindows(30))
       | "Combine" >> beam.transforms.core.CombineGlobally(CombineFn).without_defaults()
       | "Output" >> beam.io.WriteToText("<GCS path or local path>"))

res = p.run()
res.wait_until_finish()
Run Code Online (Sandbox Code Playgroud)

我在本地环境中运行该程序没有问题。

python main.py
Run Code Online (Sandbox Code Playgroud)

它在本地运行,但可以从指定的Pub / Sub主题读取,并且每隔30秒就会按预期写入指定的GCS路径。

但是现在的问题是,当我在Google Cloud Platform(即Cloud Dataflow)上运行它时,它不断发出神秘的异常。

java.util.concurrent.ExecutionException: java.lang.RuntimeException: Error received from SDK harness for instruction -1096: Traceback (most …
Run Code Online (Sandbox Code Playgroud)

python google-cloud-pubsub google-cloud-dataflow apache-beam

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

x86-64 GAS Intel 语法中像“[RIP + _a]”这样的 RIP 相关变量引用如何工作?

考虑 x64 Intel 程序集中的以下变量引用,其中变量a.data节中声明:

mov eax, dword ptr [rip + _a]
Run Code Online (Sandbox Code Playgroud)

我很难理解这个变量引用是如何工作的。既然a是对应于变量运行时地址的符号(带重定位),如何[rip + _a]解引用正确的内存位置a?事实上,rip保存当前指令的地址,它是一个大的正整数,所以加法会导致错误的地址a

相反,如果我使用 x86 语法(非常直观):

mov eax, dword ptr [_a]
Run Code Online (Sandbox Code Playgroud)

,我收到以下错误:64 位模式不支持 32 位绝对寻址

有什么解释吗?

  1 int a = 5;
  2 
  3 int main() {
  4     int b = a;
  5     return b;
  6 }   
Run Code Online (Sandbox Code Playgroud)

编译gcc -S -masm=intel abs_ref.c -o abs_ref::

  1     .section    __TEXT,__text,regular,pure_instructions
  2     .build_version macos, 10, 14
  3 …
Run Code Online (Sandbox Code Playgroud)

assembly x86-64 gnu-assembler intel-syntax addressing-mode

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

有没有办法检查颤振中的互联网连接强度?

我正在尝试将一些多媒体文件(图像、音频和视频)上传到我的服务器,并且我只想在互联网连接稳定的情况下上传这些文件。有没有具体的方法来实现这一目标?

flutter

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

如果用户拒绝摄像头访问,则无法显示警报

如果用户拒绝相机访问,我将显示一个带有取消和设置按钮的警报以显示它。但代码不起作用。

@IBAction func ProfileImageButton(_ sender: UIButton) {
        print("profile image Button is pressed")
        let imagePickerController = UIImagePickerController()
        imagePickerController.delegate = self
        profileimgbool = true
        let actionSheet = UIAlertController(title: "Photo Source", message: "choose a Source", preferredStyle: .actionSheet)

        actionSheet.addAction(UIAlertAction(title: "Camera", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .camera
            self.present(imagePickerController, animated: true, completion: nil)

        }))

        actionSheet.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .photoLibrary
            self.present(imagePickerController, animated: true, completion: nil)}))

        actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))



        self.present(actionSheet, animated: true, completion: nil)

    }

 func checkCameraPermission() …
Run Code Online (Sandbox Code Playgroud)

iphone xcode alert objective-c ios

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

方法不允许 - Django Rest Framework

我在更新时遇到错误.当我添加数据时,它会成功添加.这个错误只是为了UpdateAPIView

{
    "detail": "Method \"POST\" not allowed."
}
Run Code Online (Sandbox Code Playgroud)

urls.py

path('groups/update/<int:pk>', views.GroupsUpdateAPIView.as_view(), name='api_groups_update'),
Run Code Online (Sandbox Code Playgroud)

Views.py

class GroupsUpdateAPIView(generics.UpdateAPIView):
    queryset = Groups.objects.all()
    serializer_class = GroupsAddSerialzer
    permission_classes = [UserIsAuthenticated]

    def perform_update(self, serializer):
        serializer.save(
            group_updated_by = self.request.auth.application.user,
        )
Run Code Online (Sandbox Code Playgroud)

Serializer.py

class GroupsAddSerialzer(serializers.ModelSerializer):

    class Meta:
        model = Groups
        fields = ['group_name', 'group_description', 'group_status']
Run Code Online (Sandbox Code Playgroud)

django django-models django-views django-rest-framework

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

使用 Jupyter 单元魔法时环境变量的范围

我想了解变量范围如何在 Jupyter 笔记本中工作。

当我创建一个包含两个单元格的bash笔记本时,导出的环境变量跨单元格边界可见:

在 [1]:

export PATH=$PATH:~/samplepath
Run Code Online (Sandbox Code Playgroud)

在 [2]:

echo $PATH
Run Code Online (Sandbox Code Playgroud)

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/myuser/samplepath

但是如果我创建一个Python笔记本并使用单元格魔法来实现相同的结果,变量似乎不再跨单元格边界可见:

在 [1]:

%%script bash
export PATH=$PATH:~/samplepath
Run Code Online (Sandbox Code Playgroud)

在 [2]:

%%script bash
echo $PATH
Run Code Online (Sandbox Code Playgroud)

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

对于不同的魔法,这种行为保持相同(即,在 echo 前面使用感叹号而不是脚本魔法给出相同的结果)。

所以,我想了解在这种情况下的范围规则是什么,以及如何制作export真正的导出变量,以便它们在整个笔记本中可见。

scope jupyter-notebook

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

如何覆盖多态性的运算符

任何人都可以向我解释我在这里做错了什么吗?

struct X {
    int x{};

    explicit X(int x) : x(x) {}

    virtual X &operator++() = 0;
};

struct OK : X {
    int ok{};

    explicit OK(int ok) : X(ok), ok(ok) {}

    X &operator++() override {
        ok += 10;
        return *this;
    }
};

struct MU : X {
    int mu{};

    explicit MU(int mu) : X(mu), mu(mu) {}

    X &operator++() override {
        mu *= 5;
        return *this;
    }
};

int main() {
    X *x_base = new OK(0);
    ++x_base;
    std::cout << x_base->x; …
Run Code Online (Sandbox Code Playgroud)

c++ polymorphism operator-overloading operators

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

无法使用Azure中的另一个MVC应用程序将Azure机器中的SSL与MongoDB连接

我在连接使用SSL配置的MongoDB时遇到问题.我在Azure虚拟机中有MongoDB企业服务器,它具有以下配置.

net:
bindIp: 0.0.0.0
port: 27017
ssl:
    CAFile: 'C:\openssl-0.9.8h-1-bin\bin\rCA.pem'
    PEMKeyFile: 'C:\openssl-0.9.8h-1-bin\bin\rser.pem'
    allowConnectionsWithoutCertificates: false
    allowInvalidHostnames: true
    mode: requireSSL
storage:
    dbPath: 'C:\data\db'
Run Code Online (Sandbox Code Playgroud)

我有一个C#示例连接mongodb和作为字节数组传递的证书数据.

MongoClientSettings settings = new MongoClientSettings
        {
            Server = new MongoServerAddress("mongo_azure_host", 27017),
            UseSsl = true,
            RetryWrites = true
        };
        settings.VerifySslCertificate = false;
        var SslCertificateData = FilePathHelper.ReadFile(Server, mySslClientCertificate);
        var certificate = new X509Certificate2(SslCertificateData, "pwd");
            settings.SslSettings = new SslSettings()
            {
                ClientCertificates = new[] { certificate }
            };
        }
        MongoClient mongoClient = new MongoClient(settings);
        mongoClient.GetServer().Connect();
Run Code Online (Sandbox Code Playgroud)

如果样本在我的本地环境中,这可以正常工作.但是,如果我在Azure Web应用程序中发布相同内容并尝试连接,则会引发以下异常

system.componentmodel.win32exception:无法识别提供给包的凭据

ssl openssl azure mongodb mongodb-.net-driver

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