标签: server-to-server

CloudKit服务器到服务器身份验证

Apple发布了一种新的方法来对服务器到服务器的CloudKit进行身份验证.https://developer.apple.com/library/content/documentation/DataManagement/Conceptual/CloudKitWebServicesReference/SettingUpWebServices.html#//apple_ref/doc/uid/TP40015240-CH24-SW6

我尝试对CloudKit和此方法进行身份验证.起初我生成了密钥对并将公钥提供给CloudKit,到目前为止没问题.

我开始构建请求标头.根据文档,它应该如下所示:

X-Apple-CloudKit-Request-KeyID: [keyID]  
X-Apple-CloudKit-Request-ISO8601Date: [date]  
X-Apple-CloudKit-Request-SignatureV1: [signature]
Run Code Online (Sandbox Code Playgroud)
  • [keyID],没问题.您可以在CloudKit仪表板中找到它.
  • [日期],我认为这应该有效:2016-02-06T20:41:00Z
  • [签名],这是问题......

文件说:

在步骤1中创建的签名.

第1步说:

连接以下参数并用冒号分隔它们.
[Current date]:[Request body]:[Web Service URL]

我问自己"为什么我必须生成密钥对?".
但第2步说:

使用您的私钥计算此消息的ECDSA签名.

也许他们的意思是用私钥签名连接签名并将其放入标题?无论如何我试过两个......

我对此(无符号)签名值的示例如下所示:

2016-02-06T20:41:00Z:YTdkNzAwYTllNjI1M2EyZTllNDNiZjVmYjg0MWFhMGRiMTE2MjI1NTYwNTA2YzQyODc4MjUwNTQ0YTE5YTg4Yw==:https://api.apple-cloudkit.com/database/1/[iCloud Container]/development/public/records/lookup  
Run Code Online (Sandbox Code Playgroud)

请求体值是SHA256哈希值,然后是base64编码的.我的问题是,我应该用":"连接,但是网址和日期也包含":".这是对的吗?(我还尝试对URL进行URL编码并删除日期中的":").
接下来,我用ECDSA签署了这个签名字符串,将其放入标题并发送.但我总是得到401"身份验证失败".为了签名,我使用ecdsa python模块,使用以下命令:

from ecdsa import SigningKey  
a = SigningKey.from_pem(open("path_to_pem_file").read())  
b = "[date]:[base64(request_body)]:/database/1/iCloud....."  
print a.sign(b).encode('hex')
Run Code Online (Sandbox Code Playgroud)

也许python模块无法正常工作.但它可以从私钥生成正确的公钥.所以我希望其他功能也能奏效.

有没有人设法使用服务器到服务器方法对CloudKit进行身份验证?它是如何正常工作的?

编辑:正确的python版本工作

from ecdsa import SigningKey
import ecdsa, base64, hashlib  

a = SigningKey.from_pem(open("path_to_pem_file").read())  
b = "[date]:[base64(sha256(request_body))]:/database/1/iCloud....."  
signature = a.sign(b, hashfunc=hashlib.sha256, sigencode=ecdsa.util.sigencode_der)  
signature = base64.b64encode(signature)
print signature #include this into the header
Run Code Online (Sandbox Code Playgroud)

authentication server-to-server cloudkit

22
推荐指数
4
解决办法
2976
查看次数

使用服务器到服务器通知和 Firebase Cloud Functions 对 iOS 和 Android 自动续订订阅进行服务器端验证

我已成功为 Google Play 实施订阅验证,但我很难理解 iOS 自动续订订阅的验证流程,想寻求您的帮助。以下是 Google Play 的高级逻辑:

新订阅验证

  1. 用户在应用程序中购买订阅。
  2. 在我的 Firestore 数据库中创建了一个SubscriptionRequest,其中包括UserID和交易令牌
  3. 云函数获取该SubscriptionRequest并使用令牌查询相关的 Google API以获取订阅详细信息。这是使用googleapis Node.js 库完成的。
  4. 最新的订阅详细信息作为Subscription保存在 Firestore 中,包括令牌(作为linkedPurchaseToken)和UserID
  5. 认购的截止日期进行评估,如果它没有过期,该用户在火力地堡被更新,标志hasActiveSubscription设置相应(包括订阅的谷歌播放标识,如monthly_sub,或annual_sub和平台,在这个案例安卓)。

Google Play 开发者通知

  1. 通过发布/订阅云功能接收通知。
  2. 将使用相关的 Google API 和通知中的令牌获取相应的订阅详细信息。
  3. 如果数据库中不存在具有该令牌的订阅(如linkedPurchaseToken),我们将尝试使用在(2)中获取的订阅详细信息中的linkedPurchaseToken在我们的数据库中查找现有订阅
  4. 如果在数据库中仍然找不到订阅,这显然意味着它是一个新订阅,它将通过上述新订阅验证过程专门处理。这样做的原因是我无法链接我的用户 ID和订阅。
  5. 如果找到订阅,它会更新为最新的详细信息。 …

notifications server-to-server ios firebase in-app-subscription

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

Google BigQuery的Google App Engine授权

我按照https://developers.google.com/bigquery/authorization#service-accounts-appengine中的说明 从app引擎到bigquery进行了一些查询.

在第2步中,我点击Google Api控制台中的团队,然后重定向到App Engine>管理>权限.我将服务帐户名称添加为电子邮件,并选择我选择开发人员的角色("可以编辑"选项不可用),然后单击"邀请用户".之后,会显示一条消息:"已将电子邮件发送至xxxxxx@appspot.gserviceaccount.com进行验证." 状态为待定.我如何确认电子邮件?,似乎这里有一个错误...

接下来,我使用以下代码进行了测试:

#!/usr/bin/env python
import httplib2
import webapp2
from google.appengine.api import memcache
from apiclient.discovery import build
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from oauth2client.appengine import AppAssertionCredentials 

# BigQuery API Settings
PROJECT_NUMBER        = 'XXXXXXXX' 

credentials = AppAssertionCredentials(scope='https://www.googleapis.com/auth/bigquery')
http        = credentials.authorize(httplib2.Http(memcache))
service     = build("bigquery", "v2", http=http)

class MainHandler(webapp2.RequestHandler):
    def get(self):
        query     = {'query':'SELECT word,count(word) AS count FROM publicdata:samples.shakespeare GROUP BY word;',
                     'timeoutMs':10000}
        jobRunner = service.jobs()
        reply     = jobRunner.query(projectId=PROJECT_NUMBER,body=query).execute()
        self.response.out.write(reply)

app = webapp2.WSGIApplication([
    ('/', …
Run Code Online (Sandbox Code Playgroud)

google-app-engine authorization server-to-server google-bigquery

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

使用node.js中的socket.io设置服务器 - 服务器SSL通信

我正在尝试使用socket.io通过ssl连接设置服务器到服务器链接.这是我的例子:

/**
 * Server
 */


var app = require('express')();
var config = require('./config');
var https = require('https');
var http = require('http');
var fs = require('fs');
var server = https.createServer({key: fs.readFileSync(config.ssl.key), cert: fs.readFileSync(config.ssl.cert), passphrase: config.ssl.passphrase}, app);
//var server = http.createServer(app);
var io = require('socket.io').listen(server);

server.listen(config.port);

app.get('/', function (req, res) {
    res.send('Server');
  //res.sendfile(__dirname + '/index.html');
});

io.sockets.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});



/**
 * Client
 */


var io = require('socket.io-client'); …
Run Code Online (Sandbox Code Playgroud)

ssl server-to-server node.js socket.io

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

使用 firebase 的 iOS 订阅 server_to_server 通知

我需要实现服务器端逻辑,以处理苹果 iOS 订阅状态​​的变化https://developer.apple.com/documentation/storekit/in-app_purchase/enabling_status_update_notifications

我的问题是:

  1. 我可以用 Firebase 做到这一点吗?即我可以在firebase服务器上放置一些例如“node.js”代码来处理来自苹果服务器的消息吗?

  2. 当我使用 测试 firebase db 服务器时nscurl --ats-diagnostics https://server.com,检查它是否与苹果 ATS(https://developer.apple.com/documentation/security/preventing_insecure_network_connections)兼容,它仅在 TLSv1.3 时失败,是否足以满足苹果 ats 的要求?

编辑 26/11/2020 - 顺便说一句,我使用 Firebase 云功能成功实现了 iOS 订阅 - 所以 Firebase 是一条路。

server-to-server subscription ios firebase

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

在 Apple iOS 应用程序内购买服务器到服务器通知沙箱中未获得 Unified_receipt

我没有得到unified_receipt应用程序购买收据中苹果沙盒中的开发人员文档中所述的信息。

根据他们的文档:https ://developer.apple.com/documentation/appstoreservernotifications/responsebody

重要的

以下顶级对象计划弃用:latest_receipt、latest_receipt_info、latest_expired_receipt 和latest_expired_receipt_info。更新任何现有代码以依赖 Unified_receipt 中的以下对象:latest_receipt 和latest_receipt_info。

但在我的回应中,我没有得到unified_receipt

server-to-server in-app-purchase ios

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

PHP脚本访问服务器到服务器到谷歌驱动器显示我自己的文件

我需要帮助才能正确决定如何使用谷歌API.

我想开发一个脚本来连接服务器到服务器(没有任何Oauth2连接)到我的谷歌驱动器文件夹,以便在网页中显示谷歌驱动器文件和文件夹.如果某些文件更新,我还会设置一个cron作业来执行操作.

这可能吗?在谷歌云平台中,我发现驱动器api具有服务器到服务器的交互.这是正确的解决方案吗?

谢谢!

php server-to-server google-drive-api google-cloud-platform

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

如果外部无法直接访问api,为什么内部服务之间的通信需要像oauth这样的授权?

这只是关于微服务架构的一般问题。如果外部世界无法访问它们,为什么 2 个或更多内部服务仍然需要像 oauth2 这样的令牌身份验证来相互通信?他们的 api 不能只是过滤内部 IP 地址吗?这种方法有什么风险?

authentication server-to-server docker kubernetes microservices

3
推荐指数
2
解决办法
636
查看次数

Android发布商权限被拒绝仅检查付款(其他api成功)

我正在尝试调用 api Purchases.products: get来验证您的购买,它会产生这样的结果

{
 "error": {
  "errors": [
   {
    "domain": "androidpublisher",
    "reason": "permissionDenied",
    "message": "The current user has insufficient permissions to perform the requested operation."
   }
  ],
  "code": 401,
  "message": "The current user has insufficient permissions to perform the requested operation."
 }
}
Run Code Online (Sandbox Code Playgroud)

这里的文档说明了你可以做什么

收到的令牌不仅仅适用于任何其他 api 的购买检查,它返回结果(Inappproducts: list is work

验证 url 构建正确,因为如果您将令牌客户端连接到服务器,那么此 api 也可以工作 - 但我需要一个服务器来进行服务器身份验证

scopes =  ['https://www.googleapis.com/auth/androidpublisher']
authorization = Google::Auth.get_application_default(scopes)

uri = "https://www.googleapis.com/androidpublisher/v3/applications/#{ENV['ANDROID_PACKAGE_NAME']}/purchases/products/#{purchasable.purchase_uuid}/tokens/#{purchase_token}?access_token=#{authorization.fetch_access_token!['access_token']}" …
Run Code Online (Sandbox Code Playgroud)

authentication server-to-server google-oauth android-inapp-purchase

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