Link, ClickAction Https Validation, before request.

オープン
#346 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp
領域
api, backend

調査の方向性

issue に示されている検証のエントリーポイントである WebpushFcmOptions.CopyAndValidate から始め、その動作を AndroidNotification.ClickAction と比較します。HTTP リンクを受け入れるべきか、検証を設定可能にすべきかをメンテナーに確認します。完了条件は、合意された動作が実装され、関連するメッセージングテストでカバーされていることです。

索引モデルが issue の本文から書いたものです。

説明

needs-triage
[REQUIRED] Step 2: Describe your environment
  • Operating System version: x64
  • Firebase SDK version: 2.3.0
  • Firebase Product: Cloud Messaging
  • .NET version: .NET 6.0
  • OS: Win10
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:

I trying to send a push messaage with:
-Webpush data (FcmOptions.Link)
-Android data (Notification.ClickAction)

Link and ClickAction same, this is http links, not https, because this is my local development enviroment.
When i developing i want to send messages with http links that pointing on my local circuit wtihout https.

Before message sends, it's validating, and validation checks link only in webpush, Android click action does not checks, and if link not https throws exception with mesage:

System.ArgumentException: 'The link options should be a valid https url.'

image

I want to have a opportunity to disable this validation, but in best case scenario remove this validation from code, beacause i dowloaded source code, and used it instead of package, after removing https checks, and FCM succeffully processed this message, when i got it and clicked on message, my browser successfully opened on http - link.

this place in source code:

using System;
using Newtonsoft.Json;

namespace FirebaseAdmin.Messaging
{
    public sealed class WebpushFcmOptions
    {
        [JsonProperty("link")]
        public string Link { get; set; }

        internal WebpushFcmOptions CopyAndValidate()
        {
            var copy = new WebpushFcmOptions()
            {
                Link = this.Link,
            };

            if (copy.Link != null)
            {
	        // this https validation, that i want to remove
                if (!Uri.IsWellFormedUriString(copy.Link, UriKind.Absolute) || !copy.Link.StartsWith("https"))
                {
                    throw new ArgumentException("The link options should be a valid https url.");
                }
            }

            return copy;
        }
    }
}

Relevant Code:
using FirebaseAdmin;
using FirebaseAdmin.Messaging;
using Google.Apis.Auth.OAuth2;

var credential = GoogleCredential.FromFile("private-key.json");

FirebaseApp.Create(new AppOptions()
{
    Credential = credential
});

var registrationToken = "CLIENT_TOKEN_HERE";

var message = new Message()
{
    Token = registrationToken,
    Notification = new Notification()
    {
        Title = "Test title.",
        Body = "Test body.",
        
    },
    Webpush = new WebpushConfig()
    {
        FcmOptions = new WebpushFcmOptions()
        {
	    // http link that will be cheked
            Link = "http://127.0.0.1:5173"
        }
    },
    Android = new AndroidConfig()
    {
        Notification = new AndroidNotification()
        {
	    // this will not checked
            ClickAction = "http://127.0.0.1:5173"
        }
    }
};

var response = await FirebaseMessaging.DefaultInstance.SendAsync(message);

Console.WriteLine($"Successfully send message to {response}");
主要言語
C#
スター
408
フォーク
147
平均マージ
1日 3時間
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

firebase/firebase-admin-dotnet のほかの issue

firebase/firebase-admin-dotnet の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。