Skip to content

[Security][mobile] signIn() の認証情報をボディ送信に変更 #339

Description

@taminororo

概要

モバイルアプリのログイン処理が password を URL クエリに連結して送信している。URL クエリに載った認証情報はアクセスログ・プロキシ・履歴に平文で残るため、リクエストボディ(JSON)で送るよう変更する。

親タスク: 認証情報を URL クエリから送らずリクエストボディに移す
前提: api 側の対応(#338)が完了していること(協調デプロイ)。

対象

mobile/lib/utils/api.dartsignIn()(L255-293)。

Future signIn(studentNumber, password) async {
  String url = constant.apiUrl +
      '/mail_auth/signin?student_number=' +
      studentNumber +
      '&password=' +
      password;
  final uri = Uri.parse(url);
  final response = await http.post(
    uri,
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Content-Type": "application/json",
    },
  );
  return json.decode(response.body);
}

現状は URL に認証情報を連結し、http.post をボディ無しで呼んでいる。

変更方針

クエリ連結を廃止し、URL はエンドポイントのみにする。認証情報はボディに JSON で載せる。既存の共通メソッド post(url, request)(L9-42, すでに body: json.encode(request) で送る作り)を使うのが素直。

Future signIn(studentNumber, password) async {
  final url = '${constant.apiUrl}/mail_auth/signin';
  return await post(url, {
    'student_number': studentNumber,
    'password': password,
  });
}

共通 post のステータス判定(201 のみ成功)と signin のレスポンス仕様が合うかは確認する。合わない場合は http.postbody: json.encode(...) を渡す形で個別実装する。

確認

  • ログインが成功し、id / roleID がレスポンスから取得できること。
  • 送信 URL に student_number= / password= が含まれないこと。

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✨Frontend-MobileMobileのフロントのタスク. 主にDart/Flutterを使用🔨修正バグや仕様と異なる箇所の修正

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions