OAuth2 ve Sosyal Giriş Entegrasyonu
Spring Security'nin OAuth2 istemci desteğini kullanarak kimlik doğrulamayı Google ve GitHub gibi güvenilir sağlayıcılara devredin.
OAuth2 ve Sosyal Giriş Entegrasyonu, CoddyKit'te ücretsiz bir Spring Boot 4 Complete Guide dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Spring Boot 4 Complete Guide öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Spring Boot 4 Complete Guide kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
What Is OAuth2?
OAuth2 is a protocol that lets users grant your app limited access to their identity at another provider, without sharing their password. It powers Login with Google, GitHub, and more.
Roles in OAuth2
Three players matter: the user (resource owner), your app (the client), and the authorization server (the provider). Spring orchestrates the handshake between them.
The Authorization Code Flow
The most common flow redirects the user to the provider, who returns an authorization code. Your app exchanges that code for tokens behind the scenes.
- Redirect to provider
- User approves
- Receive code, exchange for token
Adding the OAuth2 Client Starter
Spring Security ships an OAuth2 client starter that handles the entire flow for you. Add the dependency to get started.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>Registering a Provider
Configure your client ID and secret in properties. Spring already knows the endpoints for common providers like Google.
spring.security.oauth2.client.registration.google.client-id=YOUR_ID
spring.security.oauth2.client.registration.google.client-secret=YOUR_SECRETEnabling Login
Call oauth2Login() in your security configuration to wire up the login page and callback handling automatically.
http.authorizeHttpRequests(a -> a.anyRequest().authenticated())
.oauth2Login(Customizer.withDefaults());Reading the Authenticated User
After login, inject the OAuth2User to access profile attributes like name and email returned by the provider.
@GetMapping("/me")
public String me(@AuthenticationPrincipal OAuth2User user) {
return user.getAttribute("email");
}Mapping Provider Roles
Providers return their own attributes. You often map them to your application's authorities so your existing access rules still apply.
OAuth2 vs OpenID Connect
OAuth2 is about authorization, while OpenID Connect adds an identity layer with an ID token. Most social logins use OIDC under the hood for authentication.
Persisting Users
On first login you typically create a local user record keyed by the provider's unique ID, linking the external identity to your own data model.
Security Considerations
Always validate redirect URIs, keep client secrets out of source control, and request only the scopes you actually need.
Quick Check
Test your understanding of OAuth2 login.
Recap
You added OAuth2 client support, registered a provider, enabled oauth2Login(), and read the authenticated user. Social login lets you offload password handling to trusted providers.
Sıkça Sorulan Sorular
“OAuth2 ve Sosyal Giriş Entegrasyonu” dersi ücretsiz mi?
Evet — “OAuth2 ve Sosyal Giriş Entegrasyonu” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Spring Boot 4 Complete Guide kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Spring Boot 4 Complete Guide kursu toplamda 4 dersten oluşur.
“OAuth2 ve Sosyal Giriş Entegrasyonu” dersinde ne öğreneceğim?
Spring Security'nin OAuth2 istemci desteğini kullanarak kimlik doğrulamayı Google ve GitHub gibi güvenilir sağlayıcılara devredin. Spring Boot 4 Complete Guide ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Spring Boot 4 Complete Guide öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Spring Boot 4 Complete Guide, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“OAuth2 ve Sosyal Giriş Entegrasyonu” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Spring Boot 4 Complete Guide dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Spring Boot 4 Complete Guide dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Spring Security Temelleri
- Kimlik Doğrulama ve Yetkilendirme
- JWT Tabanlı Güvenlik
- OAuth2 ve Sosyal Giriş Entegrasyonu