Oauth: Display friendly error message when role_attribute_strict=true and no valid role found (#57818)

* Oauth: change error type to a struct that unwraps into a social error

* Oauth: Handle empty role in error and fix unwrap

* Oauth: provide more informatio in error

* Oauth: return InvalidBasicRoleError

* Oauth: Fix tests

* Login: Remove casing

* Oath: Change to warning logs
This commit is contained in:
Karl Persson
2022-10-31 09:11:31 +01:00
committed by GitHub
parent 89d917b196
commit 052d1426f9
8 changed files with 33 additions and 12 deletions

View File

@@ -99,7 +99,7 @@ func TestSocialGitlab_UserInfo(t *testing.T) {
UserRespBody: editorUserRespBody,
GroupsRespBody: "[" + strings.Join([]string{}, ",") + "]",
RoleAttributePath: gitlabAttrPath,
ExpectedError: ErrInvalidBasicRole,
ExpectedError: &InvalidBasicRoleError{idP: "Gitlab"},
},
{ // Edge case, no match, no strict mode and no fallback => User has an empty role
Name: "Fallback with no default will create a user with an empty role",
@@ -117,7 +117,7 @@ func TestSocialGitlab_UserInfo(t *testing.T) {
UserRespBody: editorUserRespBody,
GroupsRespBody: "[" + strings.Join([]string{editorGroup}, ",") + "]",
RoleAttributePath: "",
ExpectedError: ErrInvalidBasicRole,
ExpectedError: &InvalidBasicRoleError{idP: "Gitlab"},
},
}