Showing posts with label backend. Show all posts
Showing posts with label backend. Show all posts

Monday, 17 August 2026

90% of developers pick the wrong authentication method.

90% of developers pick the wrong authentication method.


Then spend months patching the consequences.

JWT, Session, OAuth 2.0, API Keys - they're not interchangeable. Each one solves a different problem.

Here's the breakdown every backend engineer should know 👇

🔹 𝗦𝗲𝘀𝘀𝗶𝗼𝗻

Server creates a session on login, stores it in Redis/DB, returns session ID via cookie.

→ Stateful. Easy to revoke. Best for traditional web apps with a single backend.

→ Weakness: doesn't scale across services without a shared store.


🔹 𝗝𝗪𝗧

Server signs a token with claims (user, expiry, scope). Client sends it on every request.

→ Stateless. Scales infinitely. Best for microservices, SPAs, mobile apps.

→ Weakness: hard to revoke before expiry, payload is visible by default.


🔹 𝗢𝗔𝘂𝘁𝗵 𝟮.𝟬

User grants third-party apps limited access via an authorization server.

→ Mixed state. Industry standard for delegation. Best for "Login with Google," GitHub access, third-party integrations.

→ Weakness: complex to implement correctly - auth code, PKCE, client credentials, device flows.


🔹 𝗔𝗣𝗜 𝗞𝗲𝘆𝘀

Static long-lived secret tied to a service or developer account.

→ Stateful. Simple to rotate. Best for server-to-server APIs, SDKs, internal services.

→ Weakness: no user identity, no expiry by default. Leaked keys are dangerous.


The rule:

→ Web app, one backend → Session

→ Microservices, mobile, SPA → JWT

→ Third-party access → OAuth 2.0

→ Server-to-server → API Keys


Picking the wrong one isn't a bug. It's a security incident waiting to happen

Which one do you use most?

Obs: All Right to Original Creator @Rocky Bhatia - Linkdin Profile

#Backend #SystemDesign#Authentication #WebDevelopment #Engineering

Friday, 5 April 2024

I working with Ansible Playbook to get a count on the output of shell command, using the following task

 


I working with Ansible Playbook to get a count on the output of shell command, using the following task,


" - name: Check running number of JVM Services shell: ps -H -fu "{{ backendAppUser }}" register: apps_count become: yes become_user: "{{ backendAppUser }}" - name: Display Register var debug: var: apps_count.stdout" , however while running the task, I am getting a following error ("apps_count.stdout": "VARIABLE IS NOT DEFINED!: 'dict object' has not attribute ''stdout"


I'll address the error, provide a solution, and create a working configuration:

Understanding the Error:

  • The error "VARIABLE IS NOT DEFINED!: 'dict object' has not attribute 'stdout'" indicates that the variable apps_count exists as a dictionary, but it does not contain a key named stdout. This means the shell command's output is not being captured as expected.

Resolving the Issue:

  1. Ensure Correct Shell Command:

    • Verify that the ps -H -fu "{{ backendAppUser }}" command produces expected output when executed manually on the target host.
    • If necessary, adjust the command or consider using Ansible's command module, as it's generally more reliable for capturing output.
  2. Modify Playbook Tasks:

    • Register Output: Use register: apps_count to capture the result of the shell command, regardless of whether it's captured under stdout or another key.

    • Check for Correct Output Structure: If the output structure is different (e.g., doesn't contain stdout), use a suitable key to access the output, such as apps_count.output or other available keys.

Working Configuration:

YAML
- name: Check running number of JVM Services
  command: ps -H -fu "{{ backendAppUser }}"
  register: apps_count
  become: yes
  become_user: "{{ backendAppUser }}"

- name: Display Register var
  debug:
    var: apps_count.output

Explanation:

  • The command module is used, as it generally captures output more reliably.
  • The register: apps_count captures the output in the apps_count variable.
  • The debug task now displays apps_count.output to ensure the correct output is accessed.

Additional Tips:

  • Use failed_when: Consider using failed_when: apps_count.rc != 0 to make the playbook fail if the command returns a non-zero exit code.
  • Explore set_fact: If you need to process the output further, use set_fact to create custom variables based on the captured output.
  • Test Thoroughly: Test the configuration with a small selection of hosts before deploying it widely.

By following these steps and using the provided configuration, you should be able to successfully capture and display the output of the shell command in your Ansible playbook.

90% of developers pick the wrong authentication method.

90% of developers pick the wrong authentication method. Then spend months patching the consequences. JWT, Session, OAuth 2.0, API Keys - the...