wso2~第三方IDP向wso2用户体系的同步
用户名正则校验位置org.wso2.carbon.user.core.common.AbstractUserStoreManager.addUser()org.wso2.carbon.user.core.common.AbstractUserStoreManager.checkUserNameValid()// org.wso2.carbon:org.wso2.carbon.user.core-4.9.0.jar // addUser() if (!checkUserNameValid(userStore.getDomainFreeName()) !UserCoreUtil.getSkipUsernamePatternValidationThreadLocal()) { }注释掉这个验证规则添加用户方法调用curl \ -X POST https://test-apim.pkulaw.com/api/identity/user/v1.0/me \ -H Content-Type: application/json \ -H Authorization: Basic YWRtaW46YWRtaW4 \ -d { user: { username: 0007aaa6-cc4c-4428-a026-a4ddfec2c965, realm: PRIMARY, password: Password12!, claims: [ { uri: http://wso2.org/claims/givenname, value: kim }, { uri: http://wso2.org/claims/emailaddress, value: kim.andersongmail.com } { uri: http://wso2.org/claims/roles, value: Internal/subscriber } ] } }返回下面状态或者直接返回HTTP 201无返回值{ code: USR-02003, message: Successful user self registration. Account verification not required., notificationChannel: null }操作成功的状态码是201并且用户会自动添加下面3个角色Internal/subscriberInternal/everyoneInternal/selfsignup用户名不合法 ,返回400状态码code为20045用户名已经存在返回409状态code为20030添加应用通过api/am/devportal/applications接口获取用户应用时如果用户还没有建立应用系统会为它添加一个默认的应用这是wso2内部实现的获取应用模拟当前用户登录并获取tokencurl \ -X POST https://test-apim.pkulaw.com/oauth2/token \ -H Content-Type: application/x-www-form-urlencoded \ --data-urlencode grant_typepassword \ --data-urlencode usernamekim2 \ --data-urlencode passwordPassword12! \ --data-urlencode scopeapim:subscribe \ --data-urlencode client_iduFZG4jF7VloJc4LEwiYIcofNb3ka \ --data-urlencode client_secretGFGPfRa961aD4M_xCL3n6I54t7Ea \ -k返回{ access_token: 9953e98a-08db-39fa-9390-63ef5cab256c, scope: apim:subscribe, token_type: Bearer, expires_in: 3600 }获取自己的应用如果没有应用系统会添加一个默认应用GET https://test-apim.pkulaw.com/api/am/devportal/applications返回{ count: 1, list: [ { applicationId: 781f3363-8fdc-4c32-8ebf-0f0e8d6846d6, name: tes, throttlingPolicy: Unlimited, description: test, status: APPROVED, groups: [ ], subscriptionCount: 0, attributes: { }, owner: 0007aaa6-cc4c-4428-a026-a4ddfec2c965, tokenType: DEFAULT, createdTime: 1767676614000, updatedTime: 1767676614000 } ], pagination: { offset: 0, limit: 25, total: 2, next: , previous: } }wso2是一个非常庞大的框架单从对用户同步这块小需求就涉及到了底层代码的修改这个小需求我拉取分析的项目有几个但最终调整代码的只有carbon-kernel项目carbon-apimgtcarbon-identity-frameworkidentity-api-serveridentity-governance