requestAuthentication详解

2023-05-16

 欢迎关注我的公众号:

 目前刚开始写一个月,一共写了18篇原创文章,文章目录如下:

istio多集群探秘,部署了50次多集群后我得出的结论

istio多集群链路追踪,附实操视频

istio防故障利器,你知道几个,istio新手不要读,太难!

istio业务权限控制,原来可以这么玩

istio实现非侵入压缩,微服务之间如何实现压缩

不懂envoyfilter也敢说精通istio系列-http-rbac-不要只会用AuthorizationPolicy配置权限

不懂envoyfilter也敢说精通istio系列-02-http-corsFilter-不要只会vs

不懂envoyfilter也敢说精通istio系列-03-http-csrf filter-再也不用再代码里写csrf逻辑了

不懂envoyfilter也敢说精通istio系列http-jwt_authn-不要只会RequestAuthorization

不懂envoyfilter也敢说精通istio系列-05-fault-filter-故障注入不止是vs

不懂envoyfilter也敢说精通istio系列-06-http-match-配置路由不只是vs

不懂envoyfilter也敢说精通istio系列-07-负载均衡配置不止是dr

不懂envoyfilter也敢说精通istio系列-08-连接池和断路器

不懂envoyfilter也敢说精通istio系列-09-http-route filter

不懂envoyfilter也敢说精通istio系列-network filter-redis proxy

不懂envoyfilter也敢说精通istio系列-network filter-HttpConnectionManager

不懂envoyfilter也敢说精通istio系列-ratelimit-istio ratelimit完全手册

学习目标

什么是RequestAuthentication

RequestAuthentication defines what request authentication methods are supported by a workload. It will reject a request if the request contains invalid authentication information, based on the configured authentication rules. A request that does not contain any authentication credentials will be accepted but will not have any authenticated identity.

就是用来配置jwt的

资源详解

FieldTypeDescriptionRequired
selectorWorkloadSelectorThe selector determines the workloads to apply the RequestAuthentication on. If not set, the policy will be applied to all workloads in the same namespace as the policy.No
jwtRulesJWTRule[]Define the list of JWTs that can be validated at the selected workloads’ proxy. A valid token will be used to extract the authenticated identity. Each rule will be activated only when a token is presented at the location recorgnized by the rule. The token will be validated based on the JWT rule config. If validation fails, the request will be rejected. Note: if more than one token is presented (at different locations), the output principal is nondeterministic.No

selector

ra-example-productpage.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }

TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6IkRIRmJwb0lVcXJZOHQyenBBMnFYZkNtcjVWTzVaRXI0UnpIVV8tZW52dlEiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjM1MzczOTExMDQsImdyb3VwcyI6WyJncm91cDEiLCJncm91cDIiXSwiaWF0IjoxNTM3MzkxMTA0LCJpc3MiOiJ0ZXN0aW5nQHNlY3VyZS5pc3Rpby5pbyIsInNjb3BlIjpbInNjb3BlMSIsInNjb3BlMiJdLCJzdWIiOiJ0ZXN0aW5nQHNlY3VyZS5pc3Rpby5pbyJ9.EdJnEZSH6X8hcyEii7c8H5lnhgjB5dwo07M5oheC8Xz8mOllyg--AHCFWHybM48reunF--oGaG6IXVngCEpVF0_P5DwsUoBgpPmK1JOaKN6_pe9sh0ZwTtdgK_RP01PuI7kUdbOTlkuUi2AO-qUyOm7Art2POzo36DLQlUXv8Ad7NBOqfQaKjE9ndaPWT7aexUsBHxmgiGbz1SyLH879f7uHYPbPKlpHU6P9S-DaKnGLaEchnoKnov7ajhrEhGXAQRukhDPKUHO9L30oPIr5IJllEQfHYtt6IZvlNUGeLUcif3wpry1R5tBXRicx2sXMQ7LyuDremDbcNy_iE76Upg

curl 192.168.198.154:30986/productpage -H "Authorization: Bearer ${TOKEN}"

jwtRules

FieldTypeDescriptionRequired
issuerstringIdentifies the issuer that issued the JWT. See issuer A JWT with different iss claim will be rejected.Example: Auth0: Secure access for everyone. But not just anyone. Example: 1234567-compute@developer.gserviceaccount.comYes
audiencesstring[]The list of JWT audiences. that are allowed to access. A JWT containing any of these audiences will be accepted.The service name will be accepted if audiences is empty.Example:audiences: - bookstore_android.apps.example.com bookstore_web.apps.example.comNo
jwksUristringURL of the provider’s public key set to validate signature of the JWT. See OpenID Discovery.Optional if the key set document can either (a) be retrieved from OpenID Discovery of the issuer or (b) inferred from the email domain of the issuer (e.g. a Google service account).Example: https://www.googleapis.com/oauth2/v1/certsNote: Only one of jwksuri and jwks should be used. jwksuri will be ignored if it does.No
jwksstringJSON Web Key Set of public keys to validate signature of the JWT. See https://auth0.com/docs/jwks.Note: Only one of jwksuri and jwks should be used. jwksuri will be ignored if it does.No
fromHeadersJWTHeader[]List of header locations from which JWT is expected. For example, below is the location spec if JWT is expected to be found in x-jwt-assertion header, and have “Bearer ” prefix:fromHeaders: - name: x-jwt-assertion prefix: "Bearer "No
fromParamsstring[]List of query parameters from which JWT is expected. For example, if JWT is provided via query parameter my_token (e.g /path?my_token=), the config is:fromParams: - "my_token"No
outputPayloadToHeaderstringThis field specifies the header name to output a successfully verified JWT payload to the backend. The forwarded data is base64_encoded(jwt_payload_in_JSON). If it is not specified, the payload will not be emitted.No
forwardOriginalTokenboolIf set to true, the orginal token will be kept for the ustream request. Default is false.No

issuer

ra-example-productpage.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }

audiences

ra-productpage-jwtrules-audiences.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    audiences:
    - "app"
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }

Audiences in Jwt are not allowed

jwt里没有audience

jwksUri

ra-productpage-jwtrules-jwksUri.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    jwksUri: http://jwt-server.istio.svc.cluster.local:8000

jwt-server.yaml

apiVersion: v1
kind: Service
metadata:
  name: jwt-server
  labels:
    app: jwt-server
spec:
  ports:
  - name: http
    port: 8000
    targetPort: 8000
  selector:
    app: jwt-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: jwt-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jwt-server
  template:
    metadata:
      labels:
        app: jwt-server
    spec:
      containers:
      - image: docker.io/istio/jwt-server:0.5
        imagePullPolicy: IfNotPresent
        name: jwt-server
        ports:
        - containerPort: 8000
---

jwks

ra-example-productpage.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }

fromHeaders

ieldTypeDescriptionRequired
namestringThe HTTP header name.Yes
prefixstringThe prefix that should be stripped before decoding the token. For example, for “Authorization: Bearer ”, prefix=“Bearer ” with a space at the end. If the header doesn’t have this exact prefix, it is considerred invalid.No

ra-productpage-jwtrules-fromHeaders.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    fromHeaders:
    - name: my-token
      prefix: test
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }

curl 192.168.198.154:30986/productpage -H "my-token: test ${TOKEN}"

fromParams

ra-productpage-jwtrules-fromParams.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    fromParams:
    - my-token
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }

curl 192.168.198.154:30986/productpage?my-token=${TOKEN}

outputPayloadToHeader

ra-productpage-jwtrules-outputPayloadToHeader.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    fromParams:
    - my-token
    outputPayloadToHeader: auth
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }

curl 192.168.198.154:30986/productpage?my-token=${TOKEN}

forwardOriginalToken

1启用网关jwt

网关不启用token转发

kubectl apply -f ra-example.yaml -n istio-system

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "jwt-example"
  namespace: istio-system
spec:
  selector:
    matchLabels:
      istio: ingressgateway
  jwtRules:
  - issuer: "testing@secure.istio.io"
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }
   # forwardOriginalToken: true  # 转发 Authorization 请求头

2启用productpage jwt

ra-productpage-jwtrules-forwardOriginalToken.yaml

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "productpage"
spec:
  selector:
    matchLabels:
      app: productpage
  jwtRules:
  - issuer: "testing@secure.istio.io"
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }

curl 192.168.198.154:30986/productpage -H "Authorization: Bearer ${TOKEN}"

访问失败

3修改网关jwt

网关启用转发token

kubectl apply -f ra-example.yaml -n istio-system

apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
  name: "jwt-example"
  namespace: istio-system
spec:
  selector:
    matchLabels:
      istio: ingressgateway
  jwtRules:
  - issuer: "testing@secure.istio.io"
    jwks: |
      { "keys":
         [
           {
             "e":"AQAB",
             "kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ",
             "kty":"RSA",
             "n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"
           }
         ]
      }
    forwardOriginalToken: true  # 转发 Authorization 请求头

4访问

curl 192.168.198.154:30986/productpage -H "Authorization: Bearer ${TOKEN}"

成功

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

requestAuthentication详解 的相关文章

  • 写给4年前开始编程序的自己

    最近在网上看到有人写了一篇关于 写给4年前没有开始做设计的自己 xff0c 突然也想写这样一篇文章 具体那篇文章的内容我并没有细读 xff0c 防止自己的思路照着他的来 首先 xff0c 我先简单介绍下自己 xff0c 好为后面的内容做一个
  • STM32单片机(七). USART串口、IIC和CAN通信

    在简单的学习过了STM32中的简单外设以及中断系统后 xff0c 在本章节中开始介绍STM32芯片中各个通信接口的配置 在计算机中 xff0c 按数据传输方式可分为串行通信以及并行通信 xff1b 按数据同步方式可分为异步通信和同步通信 x
  • VINS-Mono论文笔记(中)

    VINS Mono论文笔记 中 前言1 初始化过程1 1 视觉重构1 2 视觉惯性联合 2 紧耦合的单目VIO系统2 1 公式2 2 imu残差2 3 视觉残差2 4 边缘化残差2 5 针对相机实时帧率的纯运动视觉惯性状态估计器2 6 im
  • Qt生成exe文件并成功运行

    Qt程序写完后 xff0c 想要生成一个exe文件 xff0c 那么可以参考以下方法 工具 xff1a Qt5 9 9 我们以程序2048为例 将左下角debug改为release xff0c 然后点击左侧 项目 xff0c 找到build
  • 【Qt入门第二篇】基础(二)编写Qt多窗口程序

    导语 程序要实现的功能是 xff1a 程序开始出现一个对话框 xff0c 按下按钮后便能进入主窗口 xff0c 如果直接关闭这个对话框 xff0c 便不能进入主窗口 xff0c 整个程序也将退出 当进入主窗口后 xff0c 我们按下按钮 x
  • Qt之统一的UI界面格式基调,漂亮的UI界面

    今天主要谈谈Qt UI界面统一样式 格式基调 的问题 xff1b 例如在window系统上 xff0c 几乎所有的窗口都有标题栏和状态栏以及中央部件 xff0c 而且每一个标题栏和状态栏以及中央部件样式都保持一致的 xff1b 但是在实际开
  • qt plaintextedit使用_qt获取lineedit的内容

    QLineEdit和QTextEdit都是文本框类 xff0c QLineEdit类是单行文本框控件 xff0c 可以输入单行字符串 QTextEdit类是多行文本框控件 xff0c 可以显示多行文本内容 xff0c 当文本内容超出控件显示
  • Qt实现表格控件

    一 概述 最近在研究QTableView支持多级表头的事情 xff0c 百度了下网上资料还是挺多的 实现的方式总的来说有2种 xff0c 效果都还不错 xff0c 最主要是搞懂其中的原理 xff0c 做到以不变应万变 实现多级表头的方式有以
  • 从h5调起原生APP到自己调起知乎页面

    转载请注明作者AndroidMsky和出处 xff1a http blog csdn net AndroidMsky article details 54316327 效果 xff1a 这篇算兴趣加技术篇 xff0c 和之前的抢红包博文和接
  • Qt经验-按钮长按事件分析

    引言 最近在做qt项目 xff0c 需要对button按钮添加一个长按事件 xff08 比如点击按钮 xff0c 开始运动 松开按钮 xff0c 运动停止 xff09 查了些许资料 xff0c xff08 差点误把QPushButton的p
  • Qt开发-鼠标事件

    引言 个人认为 xff0c 事件机制是Qt最难以理解且最为精妙的一部分 事件主要分为两种 xff1a 在与用户交互时发生 比如按下鼠标 xff08 mousePressEvent xff09 xff0c 敲击键盘 xff08 keyPres
  • Qt Creator工具介绍与使用

    如今 Qt Creator 功能十分强大了 xff0c 包含项目模板生成 代码编辑 UI 设计 QML 界面编辑 调试程序 上下文帮助等丰富功能 xff0c 本文就详细的介绍一下如何使用 Qt 在很长的一段时间内都没有自己的开发环境 xff
  • Qt 封装HTTP网络工具类HttpClient

    一 前言 Qt 使用 QNetworkAccessManager 访问网络 xff0c 这里对其进行了简单的封装 xff0c 访问网络的代码可以简化为 1 GET 请求无参数 HttpClient 34 http localhost 808
  • Qt——线程与定时器

    一 定时器QTimer类 The QTimer class provides repetitive and single shot timers The QTimer class provides a high level programm
  • MQTT连接阿里云IoT

    我们先来看看官方提供的MQTT连接说明 xff0c 如下 xff1a 根据该文档 xff0c 我们大致了解了各个参数的封装方式 xff0c 那么接下来我们就通过QtMqtt的接口来传入这些参数并连接到阿里云IOT 代码片段 来看一些基本的参
  • Qt小程序之QQ登录窗口输入框控件

    代码之路 整体思路即根据focusInEvent和focusOutEvent事件判断焦点是否在输入框中 xff0c 同时重写setPlaceholderText方法 xff0c 把最开始设置的占位字符保存下来 xff0c 然后焦点进入的时候
  • Qt 自定义日志类

    一 前言 C 43 43 中比较不错的日志工具有 log4cxx xff0c log4qt 等 xff0c 但是它们都不能和 qDebug qInfo 等有机的结合在一起 xff0c 所以在 Qt 中使用总觉得不够舒服 xff0c 感谢 Q
  • 在Qt程序中使用C++11线程std::thread处理耗时操作

    Qt界面程序通常什么情况下要使用到线程 xff1f Qt界面程序在调用接口处理时间较长的任务时 如连接网络 复制文件等等耗时操作 xff0c 界面在等待接口返回前会导致卡死 为了不让界面卡死 xff0c 可以使用一个子线程来处理耗时任务 x
  • 学习stm32单片机,必备工具和软件,你知道几个?

    大家好 xff0c 我是华维的麦琪 今天给大家介绍下 xff0c 学习stm32需要用到那些硬件和软件 xff0c 对于学习stm32单片机的学习者 xff0c 要添置必要的学习和开发工具 xff0c 搭建一个最基本的学习平台 xff0c

随机推荐

  • 关于android UI适配的一些思考

    作为前端工程师 xff0c 界面效果 xff0c 效率 肯定是第一要务 面对安卓庞大的机型和屏幕对开发者的要求也就越来越高了 今天笔者就自己对UI适配的一些经验进行一个简短的总结 1 关于xml中写死dp的思考 首先我们应该先把问题抛出 x
  • 单片机编程用什么软件?单片机开发软件有哪些?华维告诉你.

    大家好 xff0c 我是华维 最近有小伙伴问我单片机编程用哪些软件 xff0c 结合我工作10年单片机经验 xff0c 在此回答一下大家的问题 单片机编程软件有很多 xff0c 什么protues仿真 Labview Pycharm等等 x
  • stm32单片机学习秘籍(完整版)

    大家好 xff0c 我是华维麦琪 xff0c 今天来分享下我们华维团队十年经验总结 xff0c 如何能快速学好stm32单片机 xff01 最近看到很多小伙伴学STM32学的一脸懵逼 xff0c 有些甚至学1年都不会 xff0c 有些虽然学
  • 深度解析,单片机运行原理,你知道吗?

    同名回复 入门资料 获取单片机入门到高级进阶教程 单片机是将中央处理单元 xff08 CPU xff09 储存器 输入输出集成在一片芯片上 xff0c 可以说单片机就是一台微型计算机 xff0c 只是和我们平常使用的计算机相比它的功能有所不
  • 玩单片机需要学数电、模电吗?

    首先我们来了解下什么是模电和数电 模拟电路 xff1a 模拟电路是指用来对模拟信号进行传输 变换 处理 放大 测量和显示等工作的电路 模拟信号是指连续变化的电信号 模拟电路是电子电路的基础 xff0c 它主要包括放大电路 信号运算和处理电路
  • 2022年入坑,互联网开发和嵌入式开发,你会选择哪个?

    前言 2022年入坑 xff0c 互联网开发和嵌入式开发 xff0c 你会选择哪个 xff1f 我想很多人会毫不犹豫的选择互联网吧 xff0c 嵌入式没有那么大众化 xff0c 没有那么多关注 xff0c 对它的概念可能没有那么清楚 今天跟
  • 入门必看,51单片机学习三步走

    回想起我初学单片机到现在已经有六年了 学习期间使用了51单片机 XX卡尔单片机 STM16 STM32等单片机 每次接触新的单片机我首先会熟悉它的基本开发 xff0c 然后再通过项目的实现去深入的了解它 大家都知道51单片机是最容易学习的
  • 【华维教学】用STM32Cube和Keil5点亮一个LED

    大家好 xff0c 我是华维 今天我们讲下用STM32CubeMX和Keil5点亮一个LED xff0c 这个项目比较简单 xff0c 大家都可以尝试下 这个就是我们今天的主角 xff0c 这款单片机芯片是STM32F030K6T6 这个开
  • 浅谈ESP8266、ESP32和STM32的区别

    大家好 xff0c 我是华维蔵鹰 xff0c 关注我可以学习更多的单片机知识 今天我们来聊聊ESP8266 ESP32和STM32 乐鑫聚布局联网领域已经有些年头了 xff0c 先是推出了ESP8266这样的低价带有wifi的芯片 xff0
  • 物联网专业未来没有前途了吗?

    大家好 xff0c 我是华维蔵鹰 xff0c 想学习单片机的同学可以关注 私信我 最近在知乎看到一个同学对物联网的前景感觉到迷茫 xff0c 原因是因为某大学的教授去他们那里讲座 xff0c 然后说他们的学校物联网的专业已经没有招新了 xf
  • 面向单片机编程(一)- 单片机该怎么学

    面向单片机编程 xff08 一 xff09 单片机该怎么学 标签 单片机 C51 单片机该怎么学 xff1f 应该从哪里入手 xff1f 要怎么使用单片机实现一个小 xff08 大 xff09 目标 xff1f 下面我也来和大家一起分享一下
  • JAVA中String的底层解析

    JAVA中String 是Final类不能被继承 JAVA 对String的处理和一般Class有所不同 这文章主要是解释一下String的存储模式和java的字符串常量池的机制 xff0c 和几个涉及底层的引用问题解析 首先提出几个问题
  • 面向单片机编程(二)-开端,点亮第一个LED

    上一章中我们已经认识了单片机 xff0c 并且完成了开发环境的搭建 xff0c 这章中我们正式开始进入单片机编程的学习 xff0c 本章的学习目标是点亮一盏LED灯 一 创建一个Keil工程 1 双击运行Keil uVision5 xff0
  • ROS2——创建ROS2工作空间

    ROS2中的工作空间类似我们常说的概念 工程 xff0c 是我们在ROS中开发具体项目的空间 xff0c 所有功能包的源码 配置 编译都在该空间下完成 我们可能会同时开发多个项目 xff0c 就会产生多个工作空间 xff0c 所以工作空间之
  • C++ Primer (暂时完结)

    C 43 43 Primer C 43 43 预备知识泛型编程第二章 开始学习C 43 43 2 1 3 C 43 43 预处理器 和iostream 文件名称空间第二章 输出输入endl控制符换行符规范的书写格式c 43 43 源码风格
  • Futaba S-BUS controlled by mbed(使用mbed控制Futaba S-BUS)

    原文地址 xff1a Futaba S BUS controlled by mbed 代码地址 xff1a SBUS Library Introduction xff08 简介 xff09 The Futaba S BUS protocol
  • STorM32 BGC 相关

    下载 storm32 bgc v130电路图 xff08 http download csdn net detail hxiaohai 9901379 xff09 drv8313器件手册 xff08 http download csdn n
  • TMC5160步进电机驱动芯片开发手记

    2018年 xff0c Trinamic推出了新的型号TMC5160 xff0c 自带6点速度曲线 StealthChop和SpreadCycle静音防抖技术等很不错的功能 xff0c 目前使用官方BOB板进行开发测试 xff0c 在初步参
  • 导航过程各坐标系之间转换

    做导航最烦人的就是坐标系之间的转换 xff0c 每次都要去推相应的公式 xff0c 所以特地写点干货 xff0c 解决你坐标系转换问题 1 经纬高转地心 xff08 1 xff09 式1中 xff0c 为纬度 xff0c 为经度 xff0c
  • requestAuthentication详解

    欢迎关注我的公众号 xff1a 目前刚开始写一个月 xff0c 一共写了18篇原创文章 xff0c 文章目录如下 xff1a istio多集群探秘 xff0c 部署了50次多集群后我得出的结论 istio多集群链路追踪 xff0c 附实操视