dbbfb747a4
- Replace InternalAuthService with TokenService using JWT tokens - Add support for token issuance, refresh, verification and revocation - Implement automatic signing key rotation with Redis storage - Add database migration checks for indexes and foreign key constraints - Update gRPC endpoints to use token-based authentication - Remove deprecated API key based authentication system - Add JSON Web Token support with HMAC-SHA256 signing - Implement refresh token handling with automatic rotation - Add token revocation by JTI and user ID - Update build configuration to include core proto files - Migrate database schema to handle token-based authentication - Add comprehensive token validation and verification logic
60 lines
2.8 KiB
Rust
60 lines
2.8 KiB
Rust
pub mod auth;
|
|
pub mod channel;
|
|
pub mod channel_settings;
|
|
pub mod member;
|
|
pub mod permission;
|
|
|
|
use std::net::SocketAddr;
|
|
|
|
use crate::pb::core::token_service_server::TokenServiceServer;
|
|
use crate::pb::im::channel_audit_service_server::ChannelAuditServiceServer;
|
|
use crate::pb::im::channel_invitation_service_server::ChannelInvitationServiceServer;
|
|
use crate::pb::im::channel_repo_link_service_server::ChannelRepoLinkServiceServer;
|
|
use crate::pb::im::channel_role_service_server::ChannelRoleServiceServer;
|
|
use crate::pb::im::channel_service_server::ChannelServiceServer;
|
|
use crate::pb::im::channel_slash_command_service_server::ChannelSlashCommandServiceServer;
|
|
use crate::pb::im::channel_webhook_service_server::ChannelWebhookServiceServer;
|
|
use crate::pb::im::custom_emoji_service_server::CustomEmojiServiceServer;
|
|
use crate::pb::im::forum_tag_service_server::ForumTagServiceServer;
|
|
use crate::pb::im::im_integration_service_server::ImIntegrationServiceServer;
|
|
use crate::pb::im::member_service_server::MemberServiceServer;
|
|
use crate::pb::im::permission_service_server::PermissionServiceServer;
|
|
use crate::pb::im::stage_service_server::StageServiceServer;
|
|
use crate::pb::im::voice_service_server::VoiceServiceServer;
|
|
use crate::service::AppService;
|
|
|
|
pub async fn start_grpc_server(
|
|
addr: SocketAddr,
|
|
service: AppService,
|
|
) -> Result<(), Box<dyn std::error::Error>> {
|
|
let token_svc = auth::TokenGrpcService::new(service.internal_auth.clone());
|
|
let channel_svc = channel::ChannelGrpcService::new(service.clone());
|
|
let member_svc = member::MemberGrpcService::new(service.clone());
|
|
let permission_svc = permission::PermissionGrpcService::new(service.clone());
|
|
|
|
let cs = channel_settings::ChannelSettingsServices::new(service);
|
|
|
|
tracing::info!(%addr, "gRPC server listening");
|
|
|
|
tonic::transport::Server::builder()
|
|
.add_service(TokenServiceServer::new(token_svc))
|
|
.add_service(ChannelServiceServer::new(channel_svc))
|
|
.add_service(MemberServiceServer::new(member_svc))
|
|
.add_service(PermissionServiceServer::new(permission_svc))
|
|
.add_service(ChannelRoleServiceServer::new(cs.channel_role))
|
|
.add_service(ChannelInvitationServiceServer::new(cs.channel_invitation))
|
|
.add_service(ChannelWebhookServiceServer::new(cs.channel_webhook))
|
|
.add_service(ChannelSlashCommandServiceServer::new(cs.channel_slash_command))
|
|
.add_service(ChannelRepoLinkServiceServer::new(cs.channel_repo_link))
|
|
.add_service(ImIntegrationServiceServer::new(cs.im_integration))
|
|
.add_service(CustomEmojiServiceServer::new(cs.custom_emoji))
|
|
.add_service(ForumTagServiceServer::new(cs.forum_tag))
|
|
.add_service(VoiceServiceServer::new(cs.voice))
|
|
.add_service(StageServiceServer::new(cs.stage))
|
|
.add_service(ChannelAuditServiceServer::new(cs.channel_audit))
|
|
.serve(addr)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|