【问题标题】:MobileHub where to store API keysMobileHub 存储 API 密钥的位置
【发布时间】:2017-10-22 10:30:33
【问题描述】:

我正在基于移动中心示例应用构建一个应用。示例应用程序的 API 密钥存储在类文件 AWS 配置中:

public class AWSConfiguration {
    // AWS MobileHub user agent string
    public static final String AWS_MOBILEHUB_USER_AGENT =
            "MobileHub ********* aws-my-sample-app-android-v0.16";
    // AMAZON COGNITO
    public static final Regions AMAZON_COGNITO_REGION =
            Regions.fromName("us-east-1");
    public static String  AMAZON_COGNITO_IDENTITY_POOL_ID =     "us-east-************6";

    // Google Client ID for Web application
    public static  String GOOGLE_CLIENT_ID ="";//"*********************.apps.googleusercontent.com";


    public static final Regions AMAZON_DYNAMODB_REGION =
            Regions.fromName("us-east-1");
    public static  String AMAZON_COGNITO_USER_POOL_ID =   "************";


    public static  String AMAZON_COGNITO_USER_POOL_CLIENT_ID =   "*************";



    public static  String AMAZON_COGNITO_USER_POOL_CLIENT_SECRET =  "*************";

    private static final AWSMobileHelperConfiguration helperConfiguration = new AWSMobileHelperConfiguration.Builder()
            .withCognitoRegion(AMAZON_COGNITO_REGION)
            .withCognitoIdentityPoolId(AMAZON_COGNITO_IDENTITY_POOL_ID)
            .withCognitoUserPool(AMAZON_COGNITO_USER_POOL_ID,
                    AMAZON_COGNITO_USER_POOL_CLIENT_ID, AMAZON_COGNITO_USER_POOL_CLIENT_SECRET)
            .build();
    /**
     * @return the configuration for AWSKit.
     */
    public static AWSMobileHelperConfiguration getAWSMobileHelperConfiguration() {

        return helperConfiguration;
    }



}

以这种方式存储客户端密钥似乎不安全。有什么风险?

我尝试将密钥隐藏在 JNI 文件中,但无法在活动中找到正确的入口点来设置密钥,然后再从移动助手调用它们。

【问题讨论】:

    标签: android java-native-interface amazon-cognito api-key aws-mobilehub


    【解决方案1】:

    如您所料,以明文形式存储通常是个坏主意。您可以使用 android 密钥库,将其加密存储(密钥越强越好),使用设备的某些唯一标识符对其进行混淆,或者通过您控制和保护的某些 API 访问它。可以使用其他一些解决方案,或上述可能性的组合。最终决定取决于您以及您的应用需要/能力是什么,但有几种方法可以隐藏它。

    【讨论】:

      【解决方案2】:

      SharedPreferences.Editor 可以是一个解决方案。 密码或类似的东西存储在SharedPreferences

      【讨论】:

        猜你喜欢
        • 2021-10-06
        • 1970-01-01
        • 2023-02-10
        • 2017-04-10
        • 1970-01-01
        • 2019-08-11
        • 2010-11-09
        • 1970-01-01
        • 2010-10-13
        相关资源
        最近更新 更多