use async_trait::async_trait; use crate::protos::auth as proto; use crate::service::AuthService; use export::{AuthApi, KenAuthError}; #[async_trait] impl AuthApi for AuthService { async fn check_health(&self) -> Result<(), KenAuthError> { self.check_health().await } async fn change_password( &self, user_id: i64, old_password_hash: &str, new_password_hash: &str, keep_session_id: &str, client_ip: &str, ) -> Result { self.change_password( user_id, old_password_hash, new_password_hash, keep_session_id, client_ip, ) .await } async fn get_mfa_status( &self, user_id: i64, ) -> Result { self.get_mfa_status(user_id).await } async fn configure_totp( &self, user_id: i64, name: &str, client_ip: &str, ) -> Result { self.configure_totp(user_id, name, client_ip).await } async fn enable_totp( &self, user_id: i64, code: &str, password_hash: &str, client_ip: &str, ) -> Result { self.enable_totp(user_id, code, password_hash, client_ip) .await } async fn disable_totp( &self, user_id: i64, code: &str, client_ip: &str, ) -> Result { self.disable_totp(user_id, code, client_ip).await } async fn regenerate_recovery_codes( &self, user_id: i64, password_hash: &str, client_ip: &str, ) -> Result { self.regenerate_recovery_codes(user_id, password_hash, client_ip) .await } async fn list_user_ssh_keys( &self, user_id: i64, include_revoked: bool, page: proto::common::v1::PageRequest, ) -> Result { self.list_user_ssh_keys(user_id, include_revoked, page) .await } async fn add_ssh_key( &self, user_id: i64, name: &str, public_key: &str, description: &str, client_ip: &str, ) -> Result { self.add_ssh_key(user_id, name, public_key, description, client_ip) .await } async fn revoke_ssh_key( &self, user_id: i64, key_id: &str, reason: &str, bump_security_version: bool, ) -> Result { self.revoke_ssh_key(user_id, key_id, reason, bump_security_version) .await } async fn list_user_sessions( &self, user_id: i64, include_revoked: bool, include_expired: bool, page: proto::common::v1::PageRequest, ) -> Result { self.list_user_sessions(user_id, include_revoked, include_expired, page) .await } async fn revoke_user_sessions( &self, user_id: i64, except_session_id: &str, reason: &str, bump_security_version: bool, ) -> Result { self.revoke_user_sessions(user_id, except_session_id, reason, bump_security_version) .await } async fn get_session( &self, user_id: i64, version: i32, session_id: &str, ) -> Result { self.get_session(user_id, version, session_id).await } async fn delete_account(&self, user_id: i64, reason: &str) -> Result<(), KenAuthError> { self.delete_account(user_id, reason).await } async fn cancel_account_deletion(&self, user_id: i64) -> Result<(), KenAuthError> { self.cancel_account_deletion(user_id).await } async fn purge_account(&self, user_id: i64) -> Result<(), KenAuthError> { self.purge_account(user_id).await } async fn batch_get_authority_users( &self, user_ids: Vec, ) -> Result, KenAuthError> { self.batch_get_authority_users(user_ids).await } async fn get_user_status( &self, user_id: i64, ) -> Result { self.get_user_status(user_id).await } async fn get_user_public_by_ref( &self, key: proto::common::v1::user_ref::Key, ) -> Result { self.get_user_public_by_ref(key).await } async fn get_authority_user( &self, user_id: i64, ) -> Result { self.get_authority_user(user_id).await } async fn update_authority_user( &self, user_id: i64, username: Option, displayname: Option, clear_displayname: bool, public_show_email: Option, version: i32, ) -> Result { self.update_authority_user( user_id, username, displayname, clear_displayname, public_show_email, version, ) .await } async fn batch_get_user_public( &self, user_ids: Vec, ) -> Result, KenAuthError> { self.batch_get_user_public(user_ids).await } async fn get_user_public( &self, user_id: i64, ) -> Result { self.get_user_public(user_id).await } async fn revoke_session( &self, user_id: i64, session_id: &str, reason: &str, ) -> Result<(), KenAuthError> { self.revoke_session(user_id, session_id, reason).await } async fn lookup_ssh_key( &self, public_key: &str, ) -> Result, KenAuthError> { self.lookup_ssh_key(public_key).await } async fn ensure_bot_user( &self, username: &str, displayname: &str, system: bool, ) -> Result { self.ensure_bot_user(username, displayname, system).await } async fn ensure_bot_member( &self, organization_id: &str, user_id: i64, role_keys: Vec, role_ids: Vec, ) -> Result { self.ensure_bot_member(organization_id, user_id, role_keys, role_ids) .await } async fn get_organization( &self, actor_user_id: i64, organization_id: &str, slug: &str, ) -> Result { self.get_organization(actor_user_id, organization_id, slug) .await } async fn get_member( &self, actor_user_id: i64, organization_id: &str, user_id: i64, ) -> Result, KenAuthError> { self.get_member(actor_user_id, organization_id, user_id) .await } async fn list_members( &self, actor_user_id: i64, organization_id: &str, include_inactive: bool, include_banned: bool, page: proto::common::v1::PageRequest, ) -> Result { self.list_members( actor_user_id, organization_id, include_inactive, include_banned, page, ) .await } async fn list_organizations( &self, actor_user_id: i64, user_id: i64, include_archived: bool, page: proto::common::v1::PageRequest, ) -> Result { self.list_organizations(actor_user_id, user_id, include_archived, page) .await } async fn list_public_organizations( &self, query: &str, page: proto::common::v1::PageRequest, ) -> Result { self.list_public_organizations(query, page).await } async fn check_permissions( &self, actor_user_id: i64, organization_id: &str, user_id: i64, permissions: Vec, ) -> Result { self.check_permissions(actor_user_id, organization_id, user_id, permissions) .await } async fn create_organization( &self, actor_user_id: i64, slug: &str, name: &str, description: &str, avatar_url: &str, join_policy: Option, allow_join: Option, require_email_verified: Option, require_mfa: Option, welcome_message: Option, member_must_enable_2fa: Option, allow_invite: Option, allow_join_level: Option, ) -> Result { self.create_organization( actor_user_id, slug, name, description, avatar_url, join_policy, allow_join, require_email_verified, require_mfa, welcome_message, member_must_enable_2fa, allow_invite, allow_join_level, ) .await } async fn update_organization( &self, actor_user_id: i64, organization_id: &str, name: Option, description: Option, avatar_url: Option, expected_version: i32, join_policy: Option, allow_join: Option, require_email_verified: Option, require_mfa: Option, welcome_message: Option, member_must_enable_2fa: Option, allow_invite: Option, allow_join_level: Option, ) -> Result { self.update_organization( actor_user_id, organization_id, name, description, avatar_url, expected_version, join_policy, allow_join, require_email_verified, require_mfa, welcome_message, member_must_enable_2fa, allow_invite, allow_join_level, ) .await } async fn archive_organization( &self, actor_user_id: i64, organization_id: &str, reason: &str, ) -> Result<(), KenAuthError> { self.archive_organization(actor_user_id, organization_id, reason) .await } async fn restore_organization( &self, actor_user_id: i64, organization_id: &str, ) -> Result<(), KenAuthError> { self.restore_organization(actor_user_id, organization_id) .await } async fn delete_organization( &self, actor_user_id: i64, organization_id: &str, force: bool, reason: &str, ) -> Result<(), KenAuthError> { self.delete_organization(actor_user_id, organization_id, force, reason) .await } async fn add_member( &self, actor_user_id: i64, organization_id: &str, user_id: i64, role: i32, role_keys: Vec, ) -> Result<(proto::v1::OrganizationMemberInfo, bool), KenAuthError> { self.add_member(actor_user_id, organization_id, user_id, role, role_keys) .await } async fn remove_member( &self, actor_user_id: i64, organization_id: &str, user_id: i64, reason: &str, ) -> Result { self.remove_member(actor_user_id, organization_id, user_id, reason) .await } async fn leave_organization( &self, actor_user_id: i64, organization_id: &str, ) -> Result { self.leave_organization(actor_user_id, organization_id) .await } async fn update_member( &self, actor_user_id: i64, organization_id: &str, user_id: i64, alias_name: Option>, alias_avatar_url: Option>, message_notifications: Option, muted: Option, mute_until: Option>, mobile_push: Option, suppress_everyone: Option, suppress_roles: Option, hide_muted_channels: Option, ) -> Result { self.update_member( actor_user_id, organization_id, user_id, alias_name, alias_avatar_url, message_notifications, muted, mute_until, mobile_push, suppress_everyone, suppress_roles, hide_muted_channels, ) .await } async fn ban_member( &self, actor_user_id: i64, organization_id: &str, user_id: i64, reason: &str, ) -> Result { self.ban_member(actor_user_id, organization_id, user_id, reason) .await } async fn unban_member( &self, actor_user_id: i64, organization_id: &str, user_id: i64, ) -> Result { self.unban_member(actor_user_id, organization_id, user_id) .await } async fn update_ban( &self, actor_user_id: i64, organization_id: &str, user_id: i64, reason: Option>, expires_at: Option>, allow_speak: Option, allow_push_repo: Option, allow_comment_any: Option, ) -> Result { self.update_ban( actor_user_id, organization_id, user_id, reason, expires_at, allow_speak, allow_push_repo, allow_comment_any, ) .await } async fn create_role( &self, actor_user_id: i64, organization_id: &str, key: &str, name: &str, description: &str, rank: i32, self_assignable: bool, permissions: Vec, ) -> Result { self.create_role( actor_user_id, organization_id, key, name, description, rank, self_assignable, permissions, ) .await } async fn update_role( &self, actor_user_id: i64, organization_id: &str, role_id: &str, name: Option, description: Option, rank: Option, self_assignable: Option, expected_version: i32, ) -> Result { self.update_role( actor_user_id, organization_id, role_id, name, description, rank, self_assignable, expected_version, ) .await } async fn set_role_permissions( &self, actor_user_id: i64, organization_id: &str, role_id: &str, permissions: Vec, ) -> Result { self.set_role_permissions(actor_user_id, organization_id, role_id, permissions) .await } async fn delete_role( &self, actor_user_id: i64, organization_id: &str, role_id: &str, ) -> Result { self.delete_role(actor_user_id, organization_id, role_id) .await } async fn assign_role( &self, actor_user_id: i64, organization_id: &str, user_id: i64, role_id: &str, ) -> Result { self.assign_role(actor_user_id, organization_id, user_id, role_id) .await } async fn unassign_role( &self, actor_user_id: i64, organization_id: &str, user_id: i64, role_id: &str, ) -> Result { self.unassign_role(actor_user_id, organization_id, user_id, role_id) .await } async fn create_invite( &self, actor_user_id: i64, organization_id: &str, method: i32, max_uses: i32, expires_at: Option, role_ids: Vec, target_user_id: i64, email: &str, ) -> Result<(proto::v1::OrganizationInviteInfo, String), KenAuthError> { self.create_invite( actor_user_id, organization_id, method, max_uses, expires_at, role_ids, target_user_id, email, ) .await } async fn revoke_invite( &self, actor_user_id: i64, organization_id: &str, invite_id: &str, ) -> Result { self.revoke_invite(actor_user_id, organization_id, invite_id) .await } async fn redeem_invite( &self, actor_user_id: i64, token: &str, ) -> Result { self.redeem_invite(actor_user_id, token).await } async fn create_join_rule( &self, actor_user_id: i64, organization_id: &str, role_id: &str, trigger: &str, matcher: &str, enabled: bool, ) -> Result { self.create_join_rule( actor_user_id, organization_id, role_id, trigger, matcher, enabled, ) .await } async fn update_join_rule( &self, actor_user_id: i64, organization_id: &str, rule_id: &str, role_id: Option, trigger: Option, matcher: Option, enabled: Option, ) -> Result { self.update_join_rule( actor_user_id, organization_id, rule_id, role_id, trigger, matcher, enabled, ) .await } async fn delete_join_rule( &self, actor_user_id: i64, organization_id: &str, rule_id: &str, ) -> Result { self.delete_join_rule(actor_user_id, organization_id, rule_id) .await } async fn create_join_request( &self, actor_user_id: i64, organization_id: &str, note: &str, ) -> Result { self.create_join_request(actor_user_id, organization_id, note) .await } async fn withdraw_join_request( &self, actor_user_id: i64, organization_id: &str, request_id: &str, ) -> Result { self.withdraw_join_request(actor_user_id, organization_id, request_id) .await } async fn approve_join_request( &self, actor_user_id: i64, organization_id: &str, request_id: &str, ) -> Result< ( proto::v1::JoinRequestInfo, Option, ), KenAuthError, > { self.approve_join_request(actor_user_id, organization_id, request_id) .await } async fn reject_join_request( &self, actor_user_id: i64, organization_id: &str, request_id: &str, note: &str, ) -> Result { self.reject_join_request(actor_user_id, organization_id, request_id, note) .await } }