wso2 - 更改 WSO2 IS 5.9.0 中用户名的正则表达式限制后,Token Introspect API 不起作用?
问题描述
我正在使用 WSO2 身份服务器并使用电子邮件作为以下文档中的用户名 - https://is.docs.wso2.com/en/5.9.0/learn/using-email-address-as-the-username/
然后在执行注册时,即使用电子邮件超过 30 个字符的 SCIM2 API 创建用户时,我收到以下错误-
{
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:Error"
],
"scimType": "invalidValue",
"detail": "31301 - Username test1233.admin@motioneducation.com is not valid. User name must be a non null string with following format, ^[\\S]{3,30}$",
"status": "400"
}
然后为了解决这个问题,我在用户存储的 deployment.toml 文件中添加了这个正则表达式 -
[user_store]
username_java_script_regex = '^[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$'
username_java_regex='^[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'
此更改修复了我的注册问题,但通过使用 wso2 /oauth2/token API 执行登录生成的令牌在 /oauth2/introspect API 中给出 401 未授权?
请帮忙........?
解决方案
由于您已启用电子邮件作为用户名,因此您还需要在授权标头中使用电子邮件用户名。下面给出了一个示例 curl 命令。
curl --location --request POST 'https://{host_name}:{port}/oauth2/introspect' --header '内容类型:application/x-www-form-urlencoded' --header '授权:基本{base64encode(emailusername:password)}' --data-urlencode 'token={access_token}'
样品请求
curl --location --request POST ' https://localhost:9443/oauth2/introspect ' --header '内容类型:application/x-www-form-urlencoded' --header '授权:基本 YWRtaW5Ad3NvMi5jb206YWRtaW4=' - -data-urlencode 'token=47f65812-c5fb-3f90-b5c0-3bbc3603578f'
仅当您发送无效凭据时才会出现 401 未经授权的错误。所以请检查您是否在授权标头中发送了有效的电子邮件用户名和有效密码
推荐阅读
- python-3.x - 错误:unindent 不匹配任何外部缩进
- python-3.x - 如何使用dict在groupby之后选择第n个项目
- java - 为什么编译器对 getter 方法说“找不到符号”?
- python - 使用while循环对给定范围内的列表值求和
- c# - 使用 TVP 的批量更新适用于 SSMS,但不适用于 C#
- c++ - 在多个 cpp 文件中包含带有定义的 h 文件
- java - getBundle() 时出现 java.util.MissingResourceException
- swift - 为什么 DatePicker 在 Date 变为 nil 时会崩溃?
- c++ - C++ 未初始化的结构成员 - 字段不存在
- c# - 是否可以使用标记将任何对象作为参数传递给 LinkButton.CommandArgument?