WECHAT MINI PROGRAM · 小程序认证
在 AC、核心交换机、BRAS、路由等设备已配置好 Portal 认证的基础上,通过微信小程序授权即可完成网络准入实名认证,并可获取用户实名手机号码等信息。文中包含小程序平台配置、OpenPortal 系统配置与完整认证步骤。
STEP BY STEP / 从平台配置到上线
AppID、AppSecret 与服务器域名请按小程序后台的实际配置填写;页末另附微信免认证放行列表。
AC、核心交换机、Bras、路由等设备,实现微信小程序认证方式网络准入认证配置,通过微信小程序授权实名认证获取用户实名手机号码等信息。
网络设备配置好Portal认证基础上,做一下配置即可实现基于微信小程序认证的网络准入实名认证方案。
如下图所示:
在Portal系统后台-【Portal管理】-【微信认证设置】中设置微信小程序的相关配置
如下图所示:
微信小程序认证的接入账户组名称配置如下图:
备注:如果不使用临时放行方案,需要在设备配置如下放行列表。
微信小程序认证同时依赖「微信客户端基础通信」与「小程序运行时」两层域名,任一层缺失都会表现为小程序白屏、扫码无响应或加载到一半失败。认证前必须放行 DNS 与下列域名。另外微信大量使用 HTTPDNS(dns.weixin.qq.com),该域名必须单独放行,只放普通 DNS 不足以让小程序跑起来。
| 域名 | 用途 |
|---|---|
weixin.qq.com | 微信主域(覆盖 long. / short. / dns. 等各子域) |
long.weixin.qq.com | 长连接 |
short.weixin.qq.com | 短连接 |
szlong.weixin.qq.com | 深圳长连接接入点 |
szshort.weixin.qq.com | 深圳短连接接入点 |
shlong.weixin.qq.com | 上海长连接接入点 |
shshort.weixin.qq.com | 上海短连接接入点 |
extshort.weixin.qq.com | 扩展短连接 |
minorshort.weixin.qq.com | 小程序短连接 |
szminorshort.weixin.qq.com | 小程序深圳短连接 |
dns.weixin.qq.com | 微信内置 DNS(HTTPDNS) |
dns.weixin.qq.com.cn | HTTPDNS 备用域 |
login.weixin.qq.com | 登录 |
login-ext.weixin.qq.com | 登录扩展 |
mp.weixin.qq.com | 公众平台 / 小程序框架页 |
open.weixin.qq.com | 开放授权(OAuth) |
| 域名 | 用途 |
|---|---|
servicewechat.com | 小程序统一网关(wx.login 等原生能力中转,强制 HTTPS / WSS) |
wx.qlogo.cn | 用户头像 |
thirdwx.qlogo.cn | 第三方授权头像 |
thirdqq.qlogo.cn | QQ 授权头像 |
qpic.cn | 图片资源 |
mmbiz.qpic.cn | 图文 / 小程序图片资源 |
dldir1.qq.com | 动态配置 / 小程序包下载 |
cube.weixinbridge.com | 多维监控上报 |
weixinbridge.com | 微信桥接上报 |
wxs.qq.com | 小程序 / 游戏资源 |
support.weixin.qq.com | 支持 / 配置 |
wifi.weixin.qq.com | 微信 WiFi 认证相关 |
wxagame.weixin.qq.com | 小游戏(按需) |
tcb.cloud.tencent.com | 小程序云开发(按需) |
dns.weixin.qq.com / dns.weixin.qq.com.cn 必须单独放行。微信客户端大量走内置 HTTPDNS,只放普通 DNS,小程序仍会加载失败。微信服务器 IP 动态变化,华为官方也提示:仅放行「获取微信服务器 IP」接口返回的地址可能不全,强烈建议按域名放行。另外 HTTPDNS 返回 IP 后终端是直连 IP 的,这部分流量匹配不到域名规则;若小程序仍加载异常,需要额外按解析出的 IP 段放行,或让 AC 代理 DNS。
华为 AC(V200R 系列)通过 free-rule-template 配置免认证规则,模板要绑定到 Portal 服务器模板,再在接口或无线服务模板下引用才生效。
system-view
free-rule-template name wxapp_auth
free-rule 1 destination ip 114.114.114.114 mask 255.255.255.255
free-rule 2 destination ip 223.5.5.5 mask 255.255.255.255
free-rule 10 destination domain weixin.qq.com
free-rule 11 destination domain mp.weixin.qq.com
free-rule 12 destination domain open.weixin.qq.com
free-rule 13 destination domain long.weixin.qq.com
free-rule 14 destination domain short.weixin.qq.com
free-rule 15 destination domain dns.weixin.qq.com
free-rule 16 destination domain dns.weixin.qq.com.cn
free-rule 17 destination domain login.weixin.qq.com
free-rule 20 destination domain servicewechat.com
free-rule 21 destination domain wx.qlogo.cn
free-rule 22 destination domain thirdwx.qlogo.cn
free-rule 23 destination domain thirdqq.qlogo.cn
free-rule 24 destination domain qpic.cn
free-rule 25 destination domain dldir1.qq.com
free-rule 26 destination domain cube.weixinbridge.com
free-rule 27 destination domain weixinbridge.com
free-rule 28 destination domain wxs.qq.com
free-rule 29 destination domain wifi.weixin.qq.com
quit
portal-server-template name wxapp_portal
free-rule-template wxapp_auth
quit
interface Vlan-interface100
portal wxapp_portal
quit
weixin.qq.com 一条即覆盖 long.weixin.qq.com / short.weixin.qq.com / dns.weixin.qq.com / login.weixin.qq.com 等子域,所以主域一定要配上。servicewechat.com、wx.qlogo.cn、qpic.cn、dldir1.qq.com、wxs.qq.com 都在 weixin.qq.com 之外,必须逐条放行。passthrough-domain name .weixin.qq.com id 1 + passthrough-domain name .servicewechat.com id 2 + ACL 6000 放行两个透传域 + free-rule acl 6000;qlogo / qpic / dldir 仍按域名逐条配置。portal apply web-server),以设备 ? 提示为准。H3C AC 在系统视图下用 portal free-rule 逐条配置免认证规则,再在接口或无线服务模板下引用 Portal 认证模板。
system-view
portal free-rule 1 destination udp 53
portal free-rule 2 destination tcp 53
portal free-rule 3 destination ip 114.114.114.114 32
portal free-rule 4 destination ip 223.5.5.5 32
portal free-rule 10 destination domain weixin.qq.com
portal free-rule 11 destination domain mp.weixin.qq.com
portal free-rule 12 destination domain open.weixin.qq.com
portal free-rule 13 destination domain long.weixin.qq.com
portal free-rule 14 destination domain short.weixin.qq.com
portal free-rule 15 destination domain dns.weixin.qq.com
portal free-rule 16 destination domain dns.weixin.qq.com.cn
portal free-rule 17 destination domain login.weixin.qq.com
portal free-rule 20 destination domain servicewechat.com
portal free-rule 21 destination domain wx.qlogo.cn
portal free-rule 22 destination domain thirdwx.qlogo.cn
portal free-rule 23 destination domain thirdqq.qlogo.cn
portal free-rule 24 destination domain qpic.cn
portal free-rule 25 destination domain dldir1.qq.com
portal free-rule 26 destination domain cube.weixinbridge.com
portal free-rule 27 destination domain weixinbridge.com
portal free-rule 28 destination domain wxs.qq.com
portal free-rule 29 destination domain wifi.weixin.qq.com
quit
interface Vlan-interface100
portal apply profile wxapp_portal
quit
portal free-rule rule-id destination domain domain-name,含义一致。servicewechat.com、dldir1.qq.com、wxs.qq.com 未放行。wx.qlogo.cn、thirdwx.qlogo.cn、qpic.cn 未放行。weixin.qq.com 主域与 dns.weixin.qq.com(HTTPDNS)是否放行。本节综合华为官方文档《使用编辑模式部署微信认证》与微信官方社区的小程序放通域名清单整理,小程序相关域名见微信官方说明,以官方文档为准。
RELATED CASES / 相关对接案例