我有一个使用cordova google maps plugin的离子应用程序。
在我的config.xml中
<plugin name="cordova-plugin-googlemaps" spec="^2.1.1">
<variable name="API_KEY_FOR_IOS" value=“$AFLKSDJFSD" />
<variable name="LOCATION_WHEN_IN_USE_DESCRIPTION" value="Show your location on the map" />
<variable name="LOCATION_ALWAYS_USAGE_DESCRIPTION" value="Trace your location on the map" />
</plugin>我假设在config.xml中存储api密钥是不安全的,但这可能是错误的。
是否有在config.xml中存储敏感变量的最佳实践
谢谢
发布于 2018-03-19 22:50:52
您可以使用secure storage来实现此目的。
import { SecureStorage, SecureStorageObject } from '@ionic-native/secure-storage';
constructor(private secureStorage: SecureStorage) { }
...
//
this.secureStorage.create('your_storage_name')
.then((storage: SecureStorageObject) => {
//get the key from storage
storage.get('google_api_key')
.then(
data => console.log(data),
error => console.log(error)
);
//set the key into storage
storage.set('key', 'value')
.then(
data => console.log(data),
error => console.log(error)
);
});https://stackoverflow.com/questions/49363375
复制相似问题