affaan-m/ECC

springboot-security

Spring Security best practices for authn/authz, validation, CSRF, secrets, headers, rate limiting, and dependency security in Java Spring Boot services.

73CollectingNetwork access
See how to use itView GitHub source
npx skills add https://github.com/affaan-m/ECC --skill "docs/tr/skills/springboot-security"
Automated source guide

Source checked Jul 28, 2026·Refresh due Oct 26, 2026

Reorganized from the pinned upstream SKILL.md

Turn springboot-security's source instructions into a guide you can follow

According to the pinned SKILL.md from affaan-m/ECC: Auth ekleme, girişi işleme, endpoint oluşturma veya gizli bilgilerle uğraşırken kullanın.

npx skills add https://github.com/affaan-m/ECC --skill "docs/tr/skills/springboot-security"
Check the pinned source

Best fit

  • Spring Security best practices for authn/authz, validation, CSRF, secrets, headers, rate limiting, and dependency security in Java Spring Boot services.

Bring this context

  • A concrete task that matches the documented purpose of springboot-security.
  • The files, examples, or context the task depends on.
  • Your constraints, target environment, and definition of done.

Expected outputs

  • A result that follows the pinned springboot-security instructions.
  • A concise record of assumptions, inputs used, and unresolved questions.
  • A final check against the source workflow and relevant permission signals.

Key source sections

Read springboot-security through these 5 source sections

Sections are extracted automatically from the pinned SKILL.md and link back to the source.

01

Ne Zaman Aktif Edilir

Kimlik doğrulama ekleme (JWT, OAuth2, session-based)

SKILL.md · Ne Zaman Aktif Edilir
Kimlik doğrulama ekleme (JWT, OAuth2, session-based)Yetkilendirme uygulama (@PreAuthorize, role-based erişim)Kullanıcı girişini doğrulama (Bean Validation, custom validator'lar)
02

Kimlik Doğrulama

İptal listesi ile stateless JWT veya opaque token'ları tercih edin

SKILL.md · Kimlik Doğrulama
İptal listesi ile stateless JWT veya opaque token'ları tercih edinSession'lar için httpOnly, Secure, SameSite=Strict cookie'leri kullanınToken'ları OncePerRequestFilter veya resource server ile doğrulayın
03

Yetkilendirme

Method güvenliğini etkinleştirin: @EnableMethodSecurity

SKILL.md · Yetkilendirme
Method güvenliğini etkinleştirin: @EnableMethodSecurity@PreAuthorize("hasRole('ADMIN')") veya @PreAuthorize("@authz.canEdit(id)") kullanınVarsayılan olarak reddedin; sadece gerekli scope'ları açığa çıkarın
04

Girdi Doğrulama

Controller'larda @Valid ile Bean Validation kullanın

SKILL.md · Girdi Doğrulama
Controller'larda @Valid ile Bean Validation kullanınDTO'lara kısıtlamalar uygulayın: @NotBlank, @Email, @Size, custom validator'larRender etmeden önce herhangi bir HTML'i whitelist ile temizleyin
05

SQL Injection Önleme

Spring Data repository'leri veya parametreli sorgular kullanın

SKILL.md · SQL Injection Önleme
Spring Data repository'leri veya parametreli sorgular kullanınNative sorgular için :param binding'leri kullanın; string'leri asla birleştirmeyin- Spring Data repository'leri veya parametreli sorgular kullanın - Native sorgular için :param binding'leri kullanın; string'leri asla birleştirmeyin

SkillSignal prompt templates

Provide the task, context, and acceptance criteria

These prompts were written by SkillSignal from the source structure; they are not upstream text.

Task-start prompt

Confirm source fit, inputs, and outputs before acting.

Use springboot-security to help me with: [specific task]. Context: [files, data, or background]. Constraints: [environment, scope, and prohibited actions]. Before acting, check the pinned SKILL.md and explain which sections apply, what inputs are still missing, and what you will deliver.

Source-guided execution

Make the Agent explicitly follow the key extracted sections.

Apply the pinned springboot-security source to [task]. Pay particular attention to these source sections: “Ne Zaman Aktif Edilir”, “Kimlik Doğrulama”, “Yetkilendirme”, “Girdi Doğrulama”, “SQL Injection Önleme”. Preserve the important decision at each step. Mark facts not covered by the source as “needs confirmation” instead of inventing them. Then verify the result against my acceptance criteria: [criteria].

Result-review prompt

Check omissions, permissions, and source drift before delivery.

Review the current springboot-security result: (1) does it satisfy the original task; (2) were any applicable steps or limits in the pinned SKILL.md missed; (3) did it perform any unauthorized file, command, network, or data action; and (4) which conclusions remain unverified? List issues first, then fix only what the source or user authorization supports.

Output checklist

Verify each item before delivery

The task matches the purpose documented in the SKILL.md.

The source section “Ne Zaman Aktif Edilir” has been checked.

The source section “Kimlik Doğrulama” has been checked.

The source section “Yetkilendirme” has been checked.

The source section “Girdi Doğrulama” has been checked.

Inputs, constraints, and acceptance criteria are explicit.

Unverified facts, compatibility, and outcome claims are clearly marked.

Any file, command, network, or data action has been reviewed.

Choose a different workflow

When another Skill is the better fit

FAQ

What does springboot-security do?

Auth ekleme, girişi işleme, endpoint oluşturma veya gizli bilgilerle uğraşırken kullanın.

How do I start using springboot-security?

The catalog detected this source-specific install command: npx skills add https://github.com/affaan-m/ECC --skill "docs/tr/skills/springboot-security". Inspect the command and pinned source before running it.

Which Agent platforms does it declare?

No dedicated Agent platform is declared in the pinned source record.

Repository stars
234,327
Repository forks
35,711
Quality
73/100
Source repository last pushed

Quality breakdown

Based on traceable docs and repository signals; stars are not treated as quality.

73/100
Documentation27/30
Specificity11/25
Maintenance20/20
Trust signals15/25
View original Skill.mdThis page is parsed directly from the repository SKILL.md without editorial rewriting. Collected: Jul 28, 2026 · about 2 min

Spring Boot Güvenlik İncelemesi

Auth ekleme, girişi işleme, endpoint oluşturma veya gizli bilgilerle uğraşırken kullanın.

Ne Zaman Aktif Edilir

  • Kimlik doğrulama ekleme (JWT, OAuth2, session-based)
  • Yetkilendirme uygulama (@PreAuthorize, role-based erişim)
  • Kullanıcı girişini doğrulama (Bean Validation, custom validator'lar)
  • CORS, CSRF veya güvenlik başlıklarını yapılandırma
  • Gizli bilgileri yönetme (Vault, ortam değişkenleri)
  • Rate limiting veya brute-force koruması ekleme
  • Bağımlılıkları CVE için tarama

Kimlik Doğrulama

  • İptal listesi ile stateless JWT veya opaque token'ları tercih edin
  • Session'lar için httpOnly, Secure, SameSite=Strict cookie'leri kullanın
  • Token'ları OncePerRequestFilter veya resource server ile doğrulayın
@Component
public class JwtAuthFilter extends OncePerRequestFilter {
  private final JwtService jwtService;

  public JwtAuthFilter(JwtService jwtService) {
    this.jwtService = jwtService;
  }

  @Override
  protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
      FilterChain chain) throws ServletException, IOException {
    String header = request.getHeader(HttpHeaders.AUTHORIZATION);
    if (header != null && header.startsWith("Bearer ")) {
      String token = header.substring(7);
      Authentication auth = jwtService.authenticate(token);
      SecurityContextHolder.getContext().setAuthentication(auth);
    }
    chain.doFilter(request, response);
  }
}

Yetkilendirme

  • Method güvenliğini etkinleştirin: @EnableMethodSecurity
  • @PreAuthorize("hasRole('ADMIN')") veya @PreAuthorize("@authz.canEdit(#id)") kullanın
  • Varsayılan olarak reddedin; sadece gerekli scope'ları açığa çıkarın
@RestController
@RequestMapping("/api/admin")
public class AdminController {

  @PreAuthorize("hasRole('ADMIN')")
  @GetMapping("/users")
  public List<UserDto> listUsers() {
    return userService.findAll();
  }

  @PreAuthorize("@authz.isOwner(#id, authentication)")
  @DeleteMapping("/users/{id}")
  public ResponseEntity<Void> deleteUser(@PathVariable Long id) {
    userService.delete(id);
    return ResponseEntity.noContent().build();
  }
}

Girdi Doğrulama

  • Controller'larda @Valid ile Bean Validation kullanın
  • DTO'lara kısıtlamalar uygulayın: @NotBlank, @Email, @Size, custom validator'lar
  • Render etmeden önce herhangi bir HTML'i whitelist ile temizleyin
// KÖTÜ: Validation yok
@PostMapping("/users")
public User createUser(@RequestBody UserDto dto) {
  return userService.create(dto);
}

// İYİ: Doğrulanmış DTO
public record CreateUserDto(
    @NotBlank @Size(max = 100) String name,
    @NotBlank @Email String email,
    @NotNull @Min(0) @Max(150) Integer age
) {}

@PostMapping("/users")
public ResponseEntity<UserDto> createUser(@Valid @RequestBody CreateUserDto dto) {
  return ResponseEntity.status(HttpStatus.CREATED)
      .body(userService.create(dto));
}

SQL Injection Önleme

  • Spring Data repository'leri veya parametreli sorgular kullanın
  • Native sorgular için :param binding'leri kullanın; string'leri asla birleştirmeyin
// KÖTÜ: Native sorguda string birleştirme
@Query(value = "SELECT * FROM users WHERE name = '" + name + "'", nativeQuery = true)

// İYİ: Parametreli native sorgu
@Query(value = "SELECT * FROM users WHERE name = :name", nativeQuery = true)
List<User> findByName(@Param("name") String name);

// İYİ: Spring Data türetilmiş sorgu (otomatik parametreli)
List<User> findByEmailAndActiveTrue(String email);

Parola Kodlama

  • Parolaları her zaman BCrypt veya Argon2 ile hash'leyin — asla düz metin saklamayın
  • Manuel hash'leme değil PasswordEncoder bean'i kullanın
@Bean
public PasswordEncoder passwordEncoder() {
  return new BCryptPasswordEncoder(12); // cost faktörü 12
}

// Servis içinde
public User register(CreateUserDto dto) {
  String hashedPassword = passwordEncoder.encode(dto.password());
  return userRepository.save(new User(dto.email(), hashedPassword));
}

CSRF Koruması

  • Tarayıcı session uygulamaları için CSRF'i etkin tutun; formlara/başlıklara token ekleyin
  • Bearer token'lı saf API'ler için CSRF'i devre dışı bırakın ve stateless auth'a güvenin
http
  .csrf(csrf -> csrf.disable())
  .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS));

Gizli Bilgi Yönetimi

  • Kaynak kodda gizli bilgi yok; env veya vault'tan yükleyin
  • application.yml'i kimlik bilgilerinden arınmış tutun; yer tutucular kullanın
  • Token'ları ve DB kimlik bilgilerini düzenli olarak döndürün
# KÖTÜ: application.yml'de sabit kodlanmış
spring:
  datasource:
    password: mySecretPassword123

# İYİ: Ortam değişkeni yer tutucu
spring:
  datasource:
    password: ${DB_PASSWORD}

# İYİ: Spring Cloud Vault entegrasyonu
spring:
  cloud:
    vault:
      uri: https://vault.example.com
      token: ${VAULT_TOKEN}

Güvenlik Başlıkları

http
  .headers(headers -> headers
    .contentSecurityPolicy(csp -> csp
      .policyDirectives("default-src 'self'"))
    .frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)
    .xssProtection(Customizer.withDefaults())
    .referrerPolicy(rp -> rp.policy(ReferrerPolicyHeaderWriter.ReferrerPolicy.NO_REFERRER)));

CORS Yapılandırması

  • CORS'u controller başına değil, güvenlik filtre seviyesinde yapılandırın
  • İzin verilen origin'leri kısıtlayın — production'da asla * kullanmayın
@Bean
public CorsConfigurationSource corsConfigurationSource() {
  CorsConfiguration config = new CorsConfiguration();
  config.setAllowedOrigins(List.of("https://app.example.com"));
  config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE"));
  config.setAllowedHeaders(List.of("Authorization", "Content-Type"));
  config.setAllowCredentials(true);
  config.setMaxAge(3600L);

  UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
  source.registerCorsConfiguration("/api/**", config);
  return source;
}

// SecurityFilterChain içinde:
http.cors(cors -> cors.configurationSource(corsConfigurationSource()));

Rate Limiting

  • Pahalı endpoint'lerde Bucket4j veya gateway seviyesi limitler uygulayın
  • Patlamalarda logla ve uyar; yeniden deneme ipuçları ile 429 döndür
// Endpoint başına rate limiting için Bucket4j kullanma
@Component
public class RateLimitFilter extends OncePerRequestFilter {
  private final Map<String, Bucket> buckets = new ConcurrentHashMap<>();

  private Bucket createBucket() {
    return Bucket.builder()
        .addLimit(Bandwidth.classic(100, Refill.intervally(100, Duration.ofMinutes(1))))
        .build();
  }

  @Override
  protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
      FilterChain chain) throws ServletException, IOException {
    String clientIp = request.getRemoteAddr();
    Bucket bucket = buckets.computeIfAbsent(clientIp, k -> createBucket());

    if (bucket.tryConsume(1)) {
      chain.doFilter(request, response);
    } else {
      response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value());
      response.getWriter().write("{\"error\": \"Rate limit exceeded\"}");
    }
  }
}

Bağımlılık Güvenliği

  • CI'da OWASP Dependency Check / Snyk çalıştırın
  • Spring Boot ve Spring Security'yi desteklenen sürümlerde tutun
  • Bilinen CVE'lerde build'leri başarısız yapın

Loglama ve PII

  • Gizli bilgileri, token'ları, parolaları veya tam PAN verilerini asla loglamayın
  • Hassas alanları redakte edin; yapılandırılmış JSON loglama kullanın

Dosya Yüklemeleri

  • Boyutu, content type'ı ve uzantıyı doğrulayın
  • Web root dışında saklayın; gerekirse tarayın

Yayın Öncesi Kontrol Listesi

  • Auth token'ları doğru şekilde doğrulanmış ve süresi dolmuş
  • Her hassas path'te yetkilendirme korumaları
  • Tüm girişler doğrulanmış ve temizlenmiş
  • String-birleştirilmiş SQL yok
  • Uygulama türü için doğru CSRF duruşu
  • Gizli bilgiler harici; hiçbiri commit edilmemiş
  • Güvenlik başlıkları yapılandırılmış
  • API'lerde rate limiting
  • Bağımlılıklar taranmış ve güncel
  • Loglar hassas verilerden arınmış

Unutmayın: Varsayılan olarak reddet, girişleri doğrula, en az ayrıcalık ve önce yapılandırma ile güvenli.

Source repo
affaan-m/ECC
Skill path
docs/tr/skills/springboot-security/SKILL.md
Commit SHA
4e973d3eaf92
Repository license
MIT
Data collected