Skip to content

Commit 73d8a76

Browse files
authored
feat(query): add more info to /v1/verify (#18882)
* feat(query): add more info to /v1/verify * z * z
1 parent a3dfc01 commit 73d8a76

File tree

1 file changed

+17
-2
lines changed
  • src/query/service/src/servers/http/v1

1 file changed

+17
-2
lines changed

src/query/service/src/servers/http/v1/verify.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use databend_common_users::UserApiProvider;
1516
use jwt_simple::prelude::Serialize;
1617
use poem::error::Result as PoemResult;
1718
use poem::web::Json;
@@ -24,6 +25,9 @@ use crate::servers::http::v1::HttpQueryContext;
2425
pub struct VerifyResponse {
2526
tenant: String,
2627
user: String,
28+
auth_type: String,
29+
is_configured: bool,
30+
default_role: String,
2731
roles: Vec<String>,
2832
}
2933

@@ -35,14 +39,25 @@ pub async fn verify_handler(ctx: &HttpQueryContext) -> PoemResult<impl IntoRespo
3539
.session
3640
.get_current_user()
3741
.map_err(HttpErrorCode::server_error)?;
42+
let is_configured = UserApiProvider::instance()
43+
.get_configured_user(&user.name)
44+
.is_some();
45+
let auth_type = user.auth_info.get_type().to_str().to_string();
46+
let default_role = user.option.default_role().cloned().unwrap_or_default();
3847
let roles = ctx
3948
.session
4049
.get_all_effective_roles()
4150
.await
42-
.map_err(HttpErrorCode::server_error)?;
51+
.map_err(HttpErrorCode::server_error)?
52+
.into_iter()
53+
.map(|r| r.name)
54+
.collect();
4355
Ok(Json(VerifyResponse {
4456
tenant: tenant.tenant_name().to_string(),
4557
user: user.name,
46-
roles: roles.into_iter().map(|r| r.name).collect(),
58+
is_configured,
59+
auth_type,
60+
default_role,
61+
roles,
4762
}))
4863
}

0 commit comments

Comments
 (0)