/amplicode-spring-skills:spring-security-configurationfrom amplicode-spring-skills
Generates a Spring Security configuration class with authentication, authorization, and HTTP protection setup. Supports OAuth2/OIDC login and JWT resource server.
Ships in amplicode-spring-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill is part of the Spring Agent Toolkit and is designed to work with the Spring MCP server (provided by the Amplicode IntelliJ plugin). Before doing anything else, check your tool list for any Spring MCP tool — they are exposed under the amplicode MCP server (e.g. get_project_summary, list_module_dependencies, get_entity_details); harnesses that flatten MCP tools into the tool list use the mcp__amplicode__ prefix on the same names.
amplicode-install skill (bundled with the Spring Agent Toolkit). It installs the Amplicode plugin and walks the user through the «Настроить Spring Agent» welcome-screen button + MCP-client restart. After it completes, the MCP tools become available — resume this skill.amplicode-install is not registered in your skill list, tell the user (in their language): "This skill needs the Amplicode IntelliJ plugin and its MCP server. Install it from https://amplicode.ru/marketplace into IntelliJ IDEA Ultimate/Community or GigaIDE, open any project, click «Настроить Spring Agent» on the Amplicode welcome screen, then restart your MCP client."Generates a @Configuration @EnableWebSecurity class with a filterChain() method, DSL chains for authentication and authorization, beans, dependencies, and properties in application.properties.
CRITICAL: Code ONLY from examples/ files. If no matching example -- STOP and ask user. CRITICAL: For questions with a fixed set of choices, prefer
AskUserQuestion> its analogue > plain text list. Plain numbered text lists are the last resort when no interactive tool is available. CRITICAL: Read the conversation context BEFORE running Step 1. Half the questions in Steps 2–3 may already be answered by the user's prompt and prior turns. Re-asking what was already said is the #1 reason this skill feels slow.
| Option | Default | Always ask? | Notes |
|---|---|---|---|
| Authentication type | — | YES | main branching |
| Disable CSRF | no | NO | |
| Disable headers | no | NO | |
| Disable anonymous access | no | NO | |
| Authorization rules | anyRequest().authenticated() | NO | |
| language | from get_project_summary | NO | auto-detected |
| bootVersion | from get_project_summary | NO | auto-detected |
| className | SecurityConfiguration | NO | suggest, confirm only |
| packageName | same as existing @Configuration | NO | auto-detected |
| appPrefix | from existing @Value properties or app | NO | auto-detected from project |
Smart defaults: If user says "use defaults", "all defaults", "default settings", or similar -- skip ALL questions where "Always ask?" = NO. Only ask mandatory questions.
Smart answer recognition: When user provides a value instead of choosing from a numbered list, accept it directly. Examples:
Batch questions: Group closely related questions into a single
AskUserQuestion call (up to 4 questions per call) when they:
Rules:
AskUserQuestion call(Recommended) and place it firstAskUserQuestion for choices; fall back to plain text lists only if the tool is unavailableBefore asking the user any question, attempt to derive the answer from the context already gathered: project summary, module dependencies, existing security configurations, prior turns of this conversation, and the user's original prompt. Only ask when the context yields no clear default or when the choice is genuinely user-specific (e.g. authentication type, authorization rules).
Hierarchy of decisions:
Context is unambiguous → decide silently, do NOT ask.
Examples: language and Boot version from get_project_summary; existing
dependencies from list_module_dependencies; packageName from existing
@Configuration classes; className = SecurityConfiguration; appPrefix
from existing @Value annotations.
Context gives a strong signal → state the decision + alternatives in one line, let the user override or stay silent. Format:
Will create SecurityConfiguration with JWT (spring-boot-starter-oauth2-resource-server found in dependencies).
Alternatives: Form Login, OIDC, LDAP, Custom. OK?
The user can answer "ok" / "yes" / silence → accept; or name an alternative → switch.
Context yields no clear default → ask with AskUserQuestion (preferred), with the recommended option first.
Mark the recommended option with (Recommended) in its label and place
it first. If no interactive choice tool is available, fall back to a
plain text list.
Context is fully empty for a critical input → ask plainly. This applies to: authentication type (when no deps hint at it), authorization rules, variant-specific settings.
AskUserQuestionWhen a question must be asked, prefer the AskUserQuestion tool over
writing a numbered list in the response body. Fall back to plain text only
if no interactive choice tool is available.
Rules for AskUserQuestion calls in this skill:
(Recommended)
appended to the label.header is a 12-char chip label (e.g. "Auth Type", "CSRF", "Headers").When AskUserQuestion is not the right tool:
NEVER ask the user for credentials of any kind (client secret, manager
password, API key, token, etc.) — not via AskUserQuestion, not in plain
text, not in any form. Secret values must not enter the conversation. For
every credential field, the skill emits an env-var placeholder
(${OAUTH_*_CLIENT_SECRET}, ${LDAP_MANAGER_PASSWORD},
${AUTHSERVER_*_CLIENT_SECRET}) into application.properties and reports
the placeholder name to the user after generation — see the per-variant
references and _properties/*/properties.md "secret handling" sections.
The question lists in Steps 2–3 and in reference files are a fallback for case 4. They are NOT a script to execute top-to-bottom. If a question's answer is already determined by principles 1–3, skip the question.
Before any MCP call, before any question, re-read the user's prompt and the prior turns of this conversation and extract whatever is already stated. This step costs nothing and prevents the most common failure mode of this skill — asking the user something they already said.
Build a mental checklist of inputs and tick off everything the user has already provided, explicitly or implicitly:
| Input | Look for in the prompt / context |
|---|---|
| authentication type | "JWT", "form login", "OIDC", "Keycloak", "LDAP", "OAuth2", "authorization server" — any direct or implied mention |
| provider | "Keycloak", "Google", "GitHub", "Okta", "AWS Cognito" — implies OIDC or JWT variant |
| authorization rules | "only for ADMIN", "public API", "all endpoints secured" |
| language | Kotlin / Java — also implied by file extensions in discussion |
| className | "name it SecurityConfig", "class name XxxConfiguration" |
| smart defaults | "use defaults", "all defaults", "default settings", "minimal configuration" |
| prior project facts | language, Boot version, dependencies — already known if discussed earlier in this conversation; do not re-fetch |
For every input that is explicitly or strongly implicitly answered: mark it as decided and skip the corresponding question in Steps 2–3. Do NOT ask "Authentication type?" if the user wrote "configure JWT" — JWT is the answer. Do NOT ask language if the user wrote "in Kotlin".
For every input that is not answered: defer to the Decision-making principle above — try to derive it from project context first (Step 1), and only then ask.
Step 0 is mental, not a tool call. Do not announce it to the user. Do not write "Step 0 done". Just internalize what the user already said before proceeding to Step 1.
Call Spring MCP tools (in parallel where possible).
| Tool | What to extract | Variable name |
|---|---|---|
get_project_summary | language, springBootVersion, moduleName, buildFile, mainPackage | language, bootMajor, moduleName, buildFile, mainPackage |
list_module_dependencies(moduleName) | artifact IDs | presentDeps |
list_application_properties_files(moduleName) | path to properties file | propsFile |
list_security_configurations | existing security configs | existingConfigs |
list_spring_security_roles | existing roles for authorize rules | existingRoles |
If multi-module project (multiple modules in get_project_summary):
Ask which module to use. Then re-call module-specific MCP tools with that module.
If existingConfigs is not empty:
{className} that does not collide with existing namesDetermine appPrefix: scan existing @Value annotations in the project for a common custom prefix
(e.g. @Value("${myapp.something}") → appPrefix = myapp). If none found, default to app.
Ask:
Authentication type?
1. Form Login (HTTP Session) -- form login with session
2. JWT (OAuth2 Resource Server) -- stateless JWT
3. OAuth2/OIDC Login -- login via external provider (Keycloak, Google, GitHub...)
4. Authorization Server -- own authorization server (Spring Boot >= 3.1)
5. LDAP -- LDAP authentication
6. Custom -- empty filterChain, only common DSL blocks
Map answer to reference file:
references/http-session.mdreferences/jwt.mdreferences/oidc.mdreferences/authorization-server.md (requires bootMajor >= 3.1 — if lower, warn user and ask to choose another type)references/ldap.mdreferences/custom.mdRead the mapped reference file and follow its questions flow. Only asked if user did NOT say "all defaults".
Each reference file specifies:
Read skeleton from examples/_skeletons/{lang}.md where {lang} = java or kotlin (from Step 1)
Create the configuration class file using the skeleton, substituting {packageName} and {className}
Read the reference file for the chosen variant. For each fragment listed:
examples/_fragments/{feature}/{lang}.mdreturn http.build();bootMajor from Step 1 (some fragments have Boot < 3.1 / Boot >= 3.1 sections — use the matching one)DSL ordering inside filterChain method (IMPORTANT — order is VARIANT-DEPENDENT):
See references/common-dsl.md → "Generation Order" for the exact ordering per variant.
Always end with return http.build();
For each bean listed in the reference:
examples/_beans/{bean-type}/{lang}.mdclientRegistrationRepository), add them to the classVariable substitution rules:
{packageName} -> from Step 1 context{className} -> from user or defaultnew org.springframework.security.web.SecurityFilterChain(...)).
When generating code, extract FQNs into import statements and use short class names
in the code body. The generated file must look like normal hand-written code._dependencies/base.md (always)bootMajor from Step 1:
bootMajorspring-boot-starter-oauth2-* → spring-boot-starter-security-oauth2-*spring-security-oauth2-authorization-server:1.1.0 (no starter)presentDeps:
buildFile from Step 1refresh_build_system_model_properties/{variant}/properties.md${...} env-var placeholders for credentials (OAUTH_*_CLIENT_SECRET, LDAP_MANAGER_PASSWORD, AUTHSERVER_*_CLIENT_SECRET), list every placeholder explicitly and instruct the user to set these env vars before running the app (shell export, IDE run configuration, or deployment secret store). Never ask the user for the secret value itself — secrets must not enter the conversation history.Before writing ANY code, verify:
http.userDetailsService(...) call is present in filterChainbootMajor: Boot 4.x uses spring-boot-starter-security-oauth2-* (not spring-boot-starter-oauth2-*); session-management concurrent sessions API changed in Boot 3.1examples/_beans/jwt-converter/java.md (opens in a new tab)examples/_beans/jwt-converter/kotlin.md (opens in a new tab)examples/_beans/ldap-auth-manager/java.md (opens in a new tab)examples/_beans/ldap-auth-manager/kotlin.md (opens in a new tab)examples/_beans/ldap-context-source/java.md (opens in a new tab)examples/_beans/ldap-context-source/kotlin.md (opens in a new tab)examples/_beans/logout-handler/java.md (opens in a new tab)examples/_beans/logout-handler/kotlin.md (opens in a new tab)examples/_beans/role-mapper/java.md (opens in a new tab)examples/_beans/role-mapper/kotlin.md (opens in a new tab)examples/_beans/user-storage/java.md (opens in a new tab)examples/_beans/user-storage/kotlin.md (opens in a new tab)examples/_dependencies/authorization-server.md (opens in a new tab)examples/_dependencies/base.md (opens in a new tab)examples/_dependencies/ldap.md (opens in a new tab)examples/_dependencies/oauth-client.md (opens in a new tab)examples/_dependencies/resource-server.md (opens in a new tab)examples/_fragments/anonymous/java.md (opens in a new tab)examples/_fragments/anonymous/kotlin.md (opens in a new tab)examples/_fragments/authorize-requests/java.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub amplicode/spring-skills --plugin spring-tools16 skills in this plugin
/amplicode-installInstalls the Amplicode IntelliJ plugin into IntelliJ IDEA (Ultimate/Community) and GigaIDE on the user's machine. Trigger explicitly when the user asks to install the Amplicode plugin into their IDE, in any language. Also trigger implicitly when another Spring Agent Toolkit skill (`spring-explore`, `spring-data-jpa`, `spring-data-jdbc`, `crud-rest-controller`, `dto-creator`, `mapper-creator`, `spring-security-configuration`, `spring-planning`, `java-debug`) detects that the Amplicode MCP server is not connected and delegates installation to this skill. After the IDE-plugin is installed, the user must open any project and click the "Настроить Spring Agent" button on the welcome screen — that is what triggers MCP auto-configuration and spring-skills install. This skill does NOT configure MCP itself. Skip GoLand, PyCharm, WebStorm, Rider, CLion, RubyMine, PhpStorm, DataGrip and other JetBrains products — only IDEA and GigaIDE are supported targets./codefmtReformat source code in this project using its own code-style settings — through the IntelliJ IDE when it's running, otherwise via the project's own formatter (Spotless / google-java-format / palantir-java-format) as a fallback. Use this whenever the user asks to format, reformat, tidy, "prettify", fix indentation, or optimize imports on Java/Kotlin/XML/etc. files — whether it's a single named file, a selected block or line range, a group of named files, or all uncommitted (git-changed) files. This skill is also normally invoked after any editing of files — apply it to the files you just created or changed once the edits are done, so the result stays consistent with the project's code style.Other plugins' skills for the same job