@@ -10,6 +10,7 @@ import (
1010 "github.com/amoylab/unla/internal/apiserver/database"
1111 apiserverHandler "github.com/amoylab/unla/internal/apiserver/handler"
1212 "github.com/amoylab/unla/internal/apiserver/middleware"
13+ "github.com/amoylab/unla/internal/auth"
1314 "github.com/amoylab/unla/internal/auth/jwt"
1415 "github.com/amoylab/unla/internal/common/cnst"
1516 "github.com/amoylab/unla/internal/common/config"
@@ -149,10 +150,25 @@ func initRouter(db database.Database, store storage.Store, ntf notifier.Notifier
149150 SecretKey : cfg .JWT .SecretKey ,
150151 Duration : cfg .JWT .Duration ,
151152 })
153+
154+ // Initialize OAuth auth service (for external providers)
155+ authService , err := auth .NewAuth (logger , cfg .Auth )
156+ if err != nil {
157+ logger .Fatal ("Failed to initialize auth service" , zap .Error (err ))
158+ }
159+
152160 authH := apiserverHandler .NewHandler (db , jwtService , mcpCfg , logger )
161+ oauthH := apiserverHandler .NewOAuthHandler (db , jwtService , authService , logger )
153162
154163 authG := r .Group ("/api/auth" )
155164 authG .POST ("/login" , authH .Login )
165+
166+ // OAuth routes
167+ authG .GET ("/oauth/providers" , oauthH .GetOAuthProviders )
168+ authG .GET ("/oauth/google/login" , oauthH .GoogleLogin )
169+ authG .GET ("/oauth/google/callback" , oauthH .GoogleCallback )
170+ authG .GET ("/oauth/github/login" , oauthH .GitHubLogin )
171+ authG .GET ("/oauth/github/callback" , oauthH .GitHubCallback )
156172
157173 // Protected routes
158174 protected := r .Group ("/api" )
0 commit comments