我有一个带有 FAB 的主屏幕,按下它时我想显示一个对话框供用户输入。
目前我正在使用showDialog()
SimpleDialog。
showDialog(
context: context,
builder: (BuildContext context) {
return SimpleDialog(
title: NormalText('New Counter Item'),
contentPadding: EdgeInsets.fromLTRB(24.0, 0.0, 24.0, 24.0),
children: <Widget>[
Container(
...
)
],
);
}
);
Run Code Online (Sandbox Code Playgroud)
但是,我似乎无法用它自定义几乎任何东西(更小、弯角并位于屏幕下方)。AlertDialog
似乎是一样的。
反正有自定义这些属性吗?
我正在尝试在 Flutter 中获取设备国家/地区(Android)。我使用了本教程,但我认为这是解决我问题的错误方法。
Locale myLocale = Localizations.localeOf(context);
print(myLocale.languageCode.toString() + ' ' + myLocale.countryCode.toString());
Run Code Online (Sandbox Code Playgroud)
基于此,我有几个问题/问题:
en US
即使我将设备语言设置为乌尔都语 - 巴基斯坦,我也总是收到。那么我错过了什么?geoLocation
并获取经度和纬度并根据该数据做出决定吗?或者有没有其他更简单的方法来获取用户所在的国家/地区?期待中的感谢。
这些类之间有什么区别?我知道WebSecurityConfigurerAdapter用于自定义我们应用程序中的“安全性”。
我做了什么:
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
CustomUserDetailsService customUserDetailsService;
@Autowired
private JwtAuthenticationEntryPoint unauthorizedHandler;
Run Code Online (Sandbox Code Playgroud)
但是我不明白AuthorizationServerConfigurerAdapter的含义。
我读了几篇文章,但听不懂。
我正在从 JSON 获取项目并将它们显示在下拉列表中。当这个人从下拉列表中选择一个项目时,我得到了选择,但所选项目没有改变。
例如,我们在列表中有 (tokyo, paris, new york)。默认选择是东京。当这个人选择巴黎时,我明白了,但下拉列表中的选择没有改变。
这是我的代码:
new DropdownButton(
value: cities.elementAt(0),
hint: new Text("Ville"),
items: cities.map((String value) {
return new DropdownMenuItem(
value: value,
child: new Row(
children: <Widget>[
new Icon(
Icons.location_city,
color: Colors.deepOrange,
),
new Text(value)
],
),
);
}).toList(),
onChanged: (String value) {
getTravelCity(value);
},
),
Run Code Online (Sandbox Code Playgroud)
当人选择一个项目时,它仍然显示默认值。
当我尝试使用 @react-navigation/bottom-tabs 时,出现以下错误:
Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run `yarn` or `npm install`.
MaterialBottomTabView@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:126353:43
MaterialBottomTabNavigator@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:126107:32
BottomTabNavigator
EnsureSingleNavigator@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:109377:24
BaseNavigationContainer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:108889:28
ThemeProvider@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:114532:21
NavigationContainerInner@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:114392:26
App
RCTView
View
RCTView
View
AppContainer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:75604:36
goout(RootComponent)@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:82460:28
Run Code Online (Sandbox Code Playgroud)
包.json
Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run `yarn` or `npm install`.
MaterialBottomTabView@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:126353:43
MaterialBottomTabNavigator@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:126107:32
BottomTabNavigator
EnsureSingleNavigator@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:109377:24
BaseNavigationContainer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:108889:28
ThemeProvider@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:114532:21
NavigationContainerInner@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:114392:26
App
RCTView
View
RCTView
View …
Run Code Online (Sandbox Code Playgroud) 在过去的十多天里,我看了看过的所有关于OAuth2和OpenID Connect的内容,但发现很多人不同意实现,这确实使我感到困惑。
据我了解,我发现的所有文章和示例都假设您要访问例如。Google日历,个人资料信息或电子邮件(例如)用google登录,但是除了我自己的API外,我不需要访问其他任何东西-我只想使用Google,Facebook等进行登录,并获取一个可以链接到自己数据库中的用户的ID-仅此而已。
我将尝试说明我的用例并将其用作示例。
图表上的注释:身份验证服务可能内置在API网关中-在本例中我并不重要,因为这与“在哪里做”无关,而是“如何以最佳方式做”,适用于诸如我的架构之类的架构,该架构用于我自己的API /微服务,而不访问Google,Facebook等。外部API
如果您可以理解上面这张图说明的内容,请告诉我是否误解了。
您在此处看到的对该体系结构的最基本要求是:
在用户进行身份验证和登录后,我不打算使用外部API。不需要访问用户的日历,电子邮件等。因此,我只需要身份验证部分,而无需其他任何东西(成功登录的证明)。所有用户访问权限都在我自己的数据库中定义。
因此想到了一些基本问题。
如果ID令牌确实仅用于客户端,则可以显示例如。当前登录的用户,无需进入数据库,我有0个用途,因为我可能会从数据库中查询用户并将其存储在redux中以供我的React前端应用程序使用。
难题:要将用户详细信息,组,角色和权限存储在JWT内还是不进行API授权?
如您在图上看到的,我正在通过网关发送所有API请求,这将(本身或通过身份验证服务)将不透明的访问令牌转换为带有标识符的某些JWT,因此我可以在图中识别用户数据库-然后验证用户是否具有必需的组,角色和权限-不是通过外部API,而是从我自己的数据库中获取,就像您在图中看到的那样。
即使每个服务可以共享JWT,以防多个服务需要相互交叉调用,这似乎对每个请求也要进行很多工作。
始终查找用户及其在db中的权限的好处自然是,一旦用户访问级别发生变化,他就立即被拒绝/授予访问权限,并且始终保持同步。如果我将用户详细信息,组,角色和权限存储在JWT中,并将其保留在客户端本地存储中,则我认为这可能会构成安全问题,并且很难更新用户信息,组,角色和权限在那个JWT里面?
在JWT中存储用户访问级别和信息的一大优势当然是,在许多情况下,我可以阻止用户调用某些API,而不必在数据库查找后确定访问权限。
因此,整个令牌翻译意味着以性能为代价提高安全性,但是通常建议这样做并值得吗?还是在JWT内部存储用户信息和组,角色,权限足够安全?
如果是,我是否将自己数据库中的所有信息存储在ID令牌,访问令牌或第3个令牌中-将什么令牌发送到API,并根据用户的访问权限确定是否应授予用户访问给定资源的权限数据库?如果不需要与ID提供程序API进行交互,是否真的需要访问令牌?还是我将所有的组,角色,权限存储并追加到由OpenID connect发出的ID令牌(对我来说似乎并不干净)内,并调用API并使用它授权我自己的API端点,即使有人说您永远不要使用ID令牌访问API?还是我要创建一个新的JWT来存储从数据库中获取的所有信息,该信息将用于确定用户是否可以访问给定的资源/ API端点?
请不要仅链接到常规规格或常规信息,因为我已经阅读了所有内容-我只是不明白如何将所有这些信息应用于我的实际用例(上图)。尝试请尽可能具体。
再次尝试尝试简化流程:
伙计们,我正在使用 HTML、Javascript 和 CSS 构建一个网站,并且我有一个文件输入,但由于某种原因它不会完全居中。
body {
width: 100%;
height: 100%;
margin: auto;
text-align: center;
}
#inp {
text-align: center;
margin: auto;
}
Run Code Online (Sandbox Code Playgroud)
<input id="inp" type="file" accept="image/*">
Run Code Online (Sandbox Code Playgroud) 我正在尝试检查 hive Metastore 中是否存在表,如果不存在,请创建该表。如果表存在,则追加数据。
我有下面的代码片段:
spark.catalog.setCurrentDatabase("db_name")
db_catalog = spark.catalog.listTables(dbName = 'table_name)
if any(table_name in row for row in db_catalog):
add data
else:
create table
Run Code Online (Sandbox Code Playgroud)
但是,我收到一个错误。
>>> ValueError: Some of types cannot be determined after inferring
Run Code Online (Sandbox Code Playgroud)
我无法解决值错误,因为在 hive Metastore 中创建的其他数据库表出现相同的错误。是否有另一种方法来检查 hive Metastore 中是否存在表?
我正在尝试使用 BLE 连接到设备,但在 Android 12 上遇到错误。我尝试了很多不同的方法,但找不到任何解决方案。如何请求蓝牙权限?
AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.bluetooth_le"
android:required="true" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Run Code Online (Sandbox Code Playgroud)
和权限请求代码
private static final String[] BLE_PERMISSIONS = new String[]{
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
};
private static final String[] ANDROID_12_BLE_PERMISSIONS = new String[]{
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.ACCESS_FINE_LOCATION,
};
public static void requestBlePermissions(Activity activity, int requestCode) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
ActivityCompat.requestPermissions(activity, ANDROID_12_BLE_PERMISSIONS, requestCode);
else
ActivityCompat.requestPermissions(activity, BLE_PERMISSIONS, requestCode); …
Run Code Online (Sandbox Code Playgroud) permissions android bluetooth bluetooth-lowenergy android-12
我有一个带有Swagger下一个依赖项的Spring Boot项目:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我有我的界面:
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
@RestController
@RequestMapping(value = "/cache")
@ApiIgnore
@Api(hidden = true)
public interface CacheController {
@RequestMapping(
value = "clear/",
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE}
)
@ApiOperation(value = "", hidden = true)
ResponseEntity<String> clearToken();
}
Run Code Online (Sandbox Code Playgroud)
注释@ApiIgnore
和@Api(hidden = true)
(我已经分别测试了它们,它们也不起作用。)对隐藏文档没有影响。仅当注释在方法上时,它才起作用,但是由于我还有其他端点要隐藏,因此我想全部隐藏它们。
有什么想法吗?
编辑:
这是我的Swagger配置:
import java.util.ArrayList;
import java.util.Arrays;
import …
Run Code Online (Sandbox Code Playgroud) flutter ×3
java ×2
spring-boot ×2
android ×1
android-12 ×1
apache-spark ×1
bluetooth ×1
css ×1
dart ×1
dropdown ×1
hive ×1
html ×1
javascript ×1
jwt ×1
oauth-2.0 ×1
permissions ×1
pyspark ×1
python-3.x ×1
react-native ×1
spring ×1
swagger-2.0 ×1
swagger-ui ×1