<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adigun Olamide on Medium]]></title>
        <description><![CDATA[Stories by Adigun Olamide on Medium]]></description>
        <link>https://medium.com/@adigunolamide200?source=rss-f04c64483c8e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Iz24o6VhVdi0zP-teXsQ7w@2x.jpeg</url>
            <title>Stories by Adigun Olamide on Medium</title>
            <link>https://medium.com/@adigunolamide200?source=rss-f04c64483c8e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 00:20:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adigunolamide200/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Go Query Parameter Validation]]></title>
            <link>https://medium.com/@adigunolamide200/go-query-parameter-validation-0f089ed4e121?source=rss-f04c64483c8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f089ed4e121</guid>
            <category><![CDATA[validation]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Adigun Olamide]]></dc:creator>
            <pubDate>Mon, 30 Dec 2024 15:48:03 GMT</pubDate>
            <atom:updated>2024-12-30T15:48:03.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*2864jNiWOoYHV7CznEnZRg.jpeg" /><figcaption>The response structure of this article</figcaption></figure><p>Being a frontend developer for most of my career, if I could list the top reasons why I’ve had back-and-forth with backend developers, they would majorly revolve around these three things:</p><ul><li>Response structure: Inconsistent or unclear response structures make it challenging to handle data effectively on the frontend.</li><li>Error Handling: Poor error handling leaves frontend developers guessing what went wrong and how to inform users appropriately.</li><li>Documentation: Lack of/outdated documentation makes integration a time-consuming guessing game.</li></ul><p>However, there’s one more silent troublemaker that often goes unnoticed until something breaks: <strong>Query Parameter Validation</strong>. which falls under the error handling category.</p><p>I had a funny yet interesting conversation with a friend who is a backend developer for advice with my transition from frontend to backend development, and he said: <em>“Fix those things you’ve always hated backend developers do.”</em></p><p>So this blog is kind of a solution to a problem I faced one time when working on a project that had a lot of filtering query params, and they weren’t validated, causing the backend to always crash and return an error of <strong>500</strong>.</p><p>In this blog, we’ll explore how to validate query parameters effectively in Go, ensuring clean, predictable, and reliable APIs for both frontend and backend developers.</p><p>Like we’ve always done, we’ll create a <strong>validation package and file</strong>, and we’ll define a <strong>struct for our error response and our validator</strong>. You can choose to structure this however best suits your frontend team 😉.</p><pre>// QueryValidationError represents an error related to query parameter validation<br>// It includes details about the parameter, its value, and an error message.<br>type QueryValidationError struct {<br>    Parameter string `json:&quot;parameter&quot;`<br>    Value     string `json:&quot;value&quot;`<br>    Message   string `json:&quot;message&quot;`<br>}<br><br>// QueryValidator is responsible for validating query parameters based on their types<br>// It holds a map of type validators where the key is the type (e.g., &quot;number&quot;, &quot;boolean&quot;)<br>// and the value is a function that validates the string value.<br>type QueryValidator struct {<br>    typeValidators map[string]func(string) bool<br>}</pre><p>And then, we’ll create the initialization function of our QueryValidator struct</p><pre>// NewQueryValidator initializes a new QueryValidator instance<br>// It sets up default validators for common types like &quot;number&quot; and &quot;boolean&quot;.<br>func NewQueryValidator() *QueryValidator {<br>    qv := &amp;QueryValidator{<br>        typeValidators: make(map[string]func(string) bool),<br>    }<br>    <br>    // Validator for numeric types (integer and float)<br>    qv.typeValidators[&quot;number&quot;] = func(v string) bool {<br>        matched, _ := regexp.MatchString(`^-?\d+(\.\d+)?$`, v)<br>        return matched<br>    }<br><br>    // Validator for boolean types (true/false, 1/0)<br>    qv.typeValidators[&quot;boolean&quot;] = func(v string) bool {<br>        v = strings.ToLower(v)<br>        return v == &quot;true&quot; || v == &quot;false&quot; || v == &quot;1&quot; || v == &quot;0&quot;<br>    }<br>    <br>    return qv<br>}</pre><p>In the initialization function, we’ve made sure we added the query types we want to validate and a function to validate them as well. this can be extended for other types like “string” e.t.c. That out of the way, we are going to create two methods one for validating query value and the other will be our main validation method</p><pre>// validateParamValue validates a query parameter&#39;s value based on its expected type<br>// - value: The actual value of the query parameter to validate<br>// - expectedType: The expected data type of the query parameter (e.g., &quot;number&quot;, &quot;boolean&quot;)<br>// Returns true if the value passes validation or if no validator exists for the expected type<br>func (qv *QueryValidator) validateParamValue(value, expectedType string) bool {<br>    // Check if a validator exists for the expected type<br>    validator, exists := qv.typeValidators[expectedType]<br>    if !exists {<br>        return true // If no validator exists, assume the value is valid<br>    }<br>    // Run the validator function for the given value<br>    return validator(value)<br>}</pre><p>If you could remember, when we initialized QueryValidator, typeValidators is a map which has a key of types (e.g., “number”, “boolean”) and holds a value of function that returns true if whatever value you pass to it’s parameter meets the constraint you have inside that function. I hope this makes a lot of sense.</p><p>Let’s bring everything all together by implementing our ValidateQuery method</p><pre>// ValidateQuery validates all query parameters based on predefined rules<br>// - c: Fiber context containing query parameters<br>// - rules: A map of expected query parameters and their expected types<br>// Returns a slice of QueryValidationError if validation fails<br>func (qv *QueryValidator) ValidateQuery(c fiber.Ctx, rules map[string]string) []QueryValidationError {<br>    var errors []QueryValidationError // Collect all validation errors<br>    <br>    // Retrieve all query parameters from the request<br>    queries := c.Queries()<br>    <br>    // Iterate over each query parameter<br>    for param, value := range queries {<br>        // Check if the parameter is defined in the validation rules<br>        // rules := map[string]string{<br>        //      &quot;age&quot;:    &quot;number&quot;,<br>        //      &quot;status&quot;: &quot;boolean&quot;,<br>        //      &quot;search&quot;: &quot;string&quot;,<br>        //  }<br>        expectedType, exists := rules[param]<br>        if !exists {<br>            // If the parameter is not expected, add an error entry<br>            errors = append(errors, QueryValidationError{<br>                Parameter: param,<br>                Value:     value,<br>                Message:   &quot;unexpected parameter&quot;,<br>            })<br>            continue<br>        }<br>        <br>        // Validate the parameter&#39;s value against its expected type<br>        if !qv.validateParamValue(value, expectedType) {<br>            errors = append(errors, QueryValidationError{<br>                Parameter: param,<br>                Value:     value,<br>                Message:   fmt.Sprintf(&quot;invalid value for type %s&quot;, expectedType),<br>            })<br>        }<br>    }<br>    <br>    // Return the collected validation errors (if any)<br>    return errors<br>}</pre><p>Fiber (the Go framework we’re using) has two ways of getting the value/values of our query param(s): c.Query(&quot;name&quot;) and c.Queries(). Depending on how many query param(s) you&#39;ll be expecting, will determine which method you&#39;ll be calling. You can check out the documentation here if you wish 🧠 Ctx | Fiber.</p><p>Now, let’s call our NewQueryValidator function in our handler so it can initialize our QueryValidator.</p><pre>func (userHandler UserHandler) GetAllUsersHandler(c fiber.Ctx) error {<br><br> validator := validation.NewQueryValidator()<br>    <br>  // Define validation rules<br>  rules := map[string]string{<br>      &quot;age&quot;:    &quot;number&quot;,<br>      &quot;status&quot;: &quot;boolean&quot;,<br>  }<br>  <br>  // Validate query parameters<br>  if errors := validator.ValidateQuery(c, rules); len(errors) &gt; 0 {<br>      return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{<br>          &quot;errors&quot;: errors,<br>      })<br>  }<br><br> users, metadata, err := userHandler.dbModel.UserDbModel.GetAllUsers()<br> if err != nil {<br>  return userHandler.InternalServerErrorResponseError(c)<br> }<br><br> return userHandler.SuccessResponse(c, &quot;All users fetched successfully&quot;, fiber.Map{<br>  &quot;users&quot;:    users,<br>  &quot;metadata&quot;: metadata,<br> })<br>}</pre><p>And just like that, we’ve implemented our very own query validation. this is one headache we’ve moved passed preventing our frontend team, screaming our name on the Slack Channel and keeping it peaceful. Hope you found this article helpful, catch you on the next one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f089ed4e121" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Server-Side JSON Field Validation in Golang]]></title>
            <link>https://medium.com/@adigunolamide200/server-side-json-field-validation-in-golang-55a16b80248e?source=rss-f04c64483c8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/55a16b80248e</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Adigun Olamide]]></dc:creator>
            <pubDate>Tue, 24 Dec 2024 01:04:43 GMT</pubDate>
            <atom:updated>2024-12-24T01:04:43.128Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*XT1ocm_8Tpf0Wg54cKLzpQ.jpeg" /></figure><p>I’ve been playing around with Golang for a while now, and I must say whatever good things you’ve heard developers say about the language out there is absolutely true. It’s a simple and fun language that makes building things easy, and with an abundance of libraries available, it becomes even more enjoyable given how little code you need to write to get things done. Shout out to all the amazing developers out there building crazy tools and libraries.</p><p>Speaking about tools, I wanted to build a simple web API so I tried Fiber <a href="https://docs.gofiber.io/">👋 Welcome | Fiber</a> you can check out more about Fiber web library and read the docs from the link.</p><p>In this article, I want to focus on one specific challenge: JSON field validation. Whether you’re building an API, processing configuration files, or handling data interchange, ensuring your JSON data meets specific requirements is crucial. While Go provides JSON marshaling and unmarshaling out of the box, real-world applications often need more sophisticated validation to enforce required fields before unmarshaling to a struct. I’ll show you how to implement JSON field validation in what will be a two-part series — the first part focusing on JSON field validation (ensuring required fields are present), and the second part covering JSON validation (validating field values against specific constraints).</p><p>Let’s start with a common scenario: you’re building an API that accepts user registration data. Before we even attempt to process this data or save it to our database, we need to ensure all required fields are present in the JSON payload. This might seem straightforward, but handling this validation elegantly while providing meaningful error messages can be tricky. We’ll explore how to build a robust validation system that catches missing or malformed fields early in the request lifecycle, saving precious processing time and providing better feedback to API consumers.</p><p>Let&#39;s start by creating a user authentication struct.</p><pre>type UserAuthenticationModel struct {<br> Email     string `json:&quot;email&quot;`<br> Password  string `json:&quot;password&quot;`<br> Username  string `json:&quot;username&quot;`<br> FirstName string `json:&quot;first_name&quot;`<br> LastName  string `json:&quot;last_name&quot;`<br>}</pre><p>And a handler function and since we’re using Fiber for this tutorial, the handler parameter is a bit different and it looks like this.</p><pre><br>func SignUpHandler(c fiber.Ctx) error {<br> user := new(models.UserAuthenticationModel) //Using new() to allocate memory for a UserAuthenticationModel struct<br><br> return nil<br>}</pre><p>That was pretty straightforward, now let’s head into our JSON field validation logic.<br>We’ll start by creating our JSON field validation function, which will contain some interesting code. I’ll leave comments in the code to explain what the function does.</p><pre>// Custom error type for invalid fields<br>type InvalidFieldError struct {<br> Fields []string<br>}<br><br>// InvalidFieldError initializtion function<br>func NewInvalidFieldError(field []string) *InvalidFieldError {<br> return &amp;InvalidFieldError{Fields: field}<br>}<br><br>// JsonFieldValidator is a function that validates JSON fields before unmarshaling into a struct<br>// Parameters:<br>// - c: fiber.Ctx - the Fiber context containing the request<br>// - expectedFields: map[string]bool - a map of field names that are allowed in the JSON<br>// - dataModel: interface{} - the struct where the JSON will be unmarshaled into<br>func JsonFieldValidator(c fiber.Ctx, expectedFields map[string]bool, dataModel interface{}) error {<br>    // Get the raw JSON body from the request<br>    body := c.BodyRaw()<br>    <br>    // Create a map to store the raw JSON fields without any struct validation<br>    var rawFields map[string]interface{}<br><br>    // First unmarshal attempt: Convert JSON into a generic map<br>    // This allows us to check field names before trying to match a struct<br>    if err := json.Unmarshal(body, &amp;rawFields); err != nil {<br>        return err  // Return error if JSON is malformed<br>    }<br><br>    // Create a slice to store any field names that weren&#39;t in our expectedFields map<br>    var unknownFields []string<br>    <br>    // Loop through all fields in the received JSON<br>    for field := range rawFields {<br>        // Check if each field exists in our expectedFields map<br>        // If it doesn&#39;t exist (!exists), add it to unknownFields<br>        if _, exists := expectedFields[field]; !exists {<br>            unknownFields = append(unknownFields, field)<br>        }<br>    }<br><br>    // If we found any unknown fields, return an error with those field names<br>    if len(unknownFields) &gt; 0 {<br>        return NewInvalidFieldError(unknownFields)<br>    }<br><br>    // If all fields are valid, perform the final unmarshal into the provided struct<br>    return json.Unmarshal(body, &amp;dataModel)<br>}</pre><p>Writing the function this way follows the SOLID principles and helps us reuse it whenever we want to validate JSON fields anywhere in our application. One rule of thumb I always follow is to ask myself: ‘Can this be written as a helper function?’ Even if you’ll only use the function once today, there’s a good chance you’ll need it again in the future. This approach to JSON validation demonstrates the Single Responsibility Principle perfectly — the function does one thing (validate JSON fields) and does it well, making it both maintainable and reusable across different parts of your application.</p><p>Please keep in mind that JsonFieldValidator returns an error if json.Unmarshal fails and if that happens, the error should look something like this unknown fields: [json fields that failed i.e emai, passwfd, usname].</p><p>We’ll be writing a separate function that converts the error interface into our own error, this is called type assertion. You’ll understand more about the function when we start coupling everything together inside our handler function for now, just walk with me.</p><pre>// This function takes in an error and attempts to convert a generic error interface into our *InvalidFieldError<br>func IsInvalidFieldError(err error) (*InvalidFieldError, bool) {<br> var invalidFieldErr *InvalidFieldError<br> ok := errors.As(err, &amp;invalidFieldErr)<br> return invalidFieldErr, ok<br>}<br><br>func (e *InvalidFieldError) Error() string {<br> return fmt.Sprintf(&quot;unknown field(s): %v&quot;, e.Fields)<br>}</pre><p>Now that we’ve created our helper function for JsonFieldValidation, time t bring everything together so it all makes sense. Going back to our handler function, let’s call our JsonFieldValidator function.</p><pre>func SignUpHandler(c fiber.Ctx) error {<br>    user := new(models.UserAuthenticationModel)<br><br>    // Call JsonFieldValidator with three arguments:<br>    // 1. The Fiber context (c) containing our request<br>    // 2. A map defining our expected fields - where:<br>    //    - Keys are the field names we expect in the JSON<br>    //    - Values are set to true to indicate they&#39;re allowed fields<br>    // 3. Our user model that will receive the validated data<br>    if err := JsonFieldValidator(c, map[string]bool{<br>        &quot;email&quot;:      true,<br>        &quot;password&quot;:   true,<br>        &quot;username&quot;:   true,<br>        &quot;first_name&quot;: true,<br>        &quot;last_name&quot;:  true,<br>    }, user); err != nil {<br>        // Note: This empty space is intentional as I want the implementation to be easy to understand<br>    }<br><br>    return nil<br>}</pre><p>The next step is to go one step further in our validation condition and return an appropriate error response to the client.</p><pre>func SignUpHandler(c fiber.Ctx) error {<br>    user := new(models.UserAuthenticationModel)<br><br>    // Call JsonFieldValidator with three arguments:<br>    // 1. The Fiber context (c) containing our request<br>    // 2. A map defining our expected fields - where:<br>    //    - Keys are the field names we expect in the JSON<br>    //    - Values are set to true to indicate they&#39;re allowed fields<br>    // 3. Our user model that will receive the validated data<br>    if err := JsonFieldValidator(c, map[string]bool{<br>        &quot;email&quot;:      true,<br>        &quot;password&quot;:   true,<br>        &quot;username&quot;:   true,<br>        &quot;first_name&quot;: true,<br>        &quot;last_name&quot;:  true,<br>    }, user); err != nil {<br>        // Call IsInvalidFieldError and pass the error argument:<br>        // If error casting is successful, return the struct of invalid JSON fiels<br>        if invalidFieldErr, ok := IsInvalidFieldError(err); ok {<br>         return  c.Status(fiber.StatusBadRequest).JSONfiber.Map{<br>          &quot;email&quot;:    &quot;user@example.com&quot;,<br>          &quot;password&quot;: &quot;yourPassword123!&quot;,<br>          &quot;username&quot;: &quot;johndoe&quot;,<br>          &quot;first_name&quot;: &quot;John&quot;,<br>          &quot;last_name&quot;: &quot;Doe&quot;,<br>         }, fiber.Map{<br>          &quot;invalid_fields&quot;: invalidFieldErr.Fields,<br>         }<br>       }<br>       // Else handle general JSON unmarshal error<br>        return  c.Status(fiber.StatusBadRequest).JSONfiber.Map{<br>          &quot;email&quot;:    &quot;user@example.com&quot;,<br>          &quot;password&quot;: &quot;yourPassword123!&quot;,<br>          &quot;username&quot;: &quot;johndoe&quot;,<br>          &quot;first_name&quot;: &quot;John&quot;,<br>          &quot;last_name&quot;: &quot;Doe&quot;,<br>         }<br>    }<br><br>    return nil<br>}</pre><p>And just like that, we have our very own JSON field validation helper function that we can reuse across our entire application. This approach not only makes our code more maintainable but also provides clear, helpful feedback to API consumers when they send incorrect data. The validator acts as our first line of defense, ensuring that requests contain exactly the fields we expect before we even attempt to process their values.</p><p>In the next article of this series, we’ll dive into JSON value validation, where we’ll explore how to ensure that these fields not only exist but also contain valid data. We’ll look at validating email formats, password requirements, string lengths, and other common constraints that real-world applications need to handle. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55a16b80248e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built a Password Strength for Our Signup Page.]]></title>
            <link>https://medium.com/@adigunolamide200/how-i-built-a-password-strength-for-our-signup-page-0962e376cfcc?source=rss-f04c64483c8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/0962e376cfcc</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Adigun Olamide]]></dc:creator>
            <pubDate>Tue, 06 Aug 2024 14:36:58 GMT</pubDate>
            <atom:updated>2024-08-06T14:36:58.903Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xZYrGlYXkR-rnQVfOkIx0g.png" /></figure><p>Cool logo in the header of the image above, don’t you think? Well, that’s Quidate. Quidate simplifies your crypto journey by offering instant cash for your digital assets. It’s the quickest way to turn your crypto holdings into spendable cash.</p><p>So here’s the thing, yeah? I was going through the designs that our Product Designer had just finished for some final changes and iterations, and I saw the password strength indicator. “Huh?” I said to myself, “And why is it like that?” Since I had already picked out the tech stack we were going to be using for the project, I gave the okay and went to work.</p><p>For this tutorial, i’ll be using a few packages/libraries which I will be listing bellow.</p><p><strong>Tech Stack</strong></p><ul><li>Nextjs (UI library)</li><li>Formik (Form Library)</li><li>Yup (Form Validuation)</li><li>Tailwind (Styling library)</li></ul><p>Since we’ll be using Formik i’ll run you through how i mostly setup Formik for any project i’m working on trust me, it’ll be a fun read.</p><p>Just like any other framework you’re using, you want to model your components for reusability and also to be extensible. That is what we’ll be doing with our Formik input component. First of, we’ll be creating a global input component that will be reused for most inputs we’ll be needing.</p><pre>import React, { RefObject } from &quot;react&quot;;<br><br>type InputProps = {<br> refElement?: RefObject&lt;HTMLDivElement&gt;;<br> label?: string;<br> className?: string;<br> containerClassName?: string;<br> labelClassName?: string;<br> inputContainerClassName?: string;<br> child?: React.ReactNode;<br> errorChild?: React.ReactNode;<br> inputType: string;<br> errorMessage?: React.ReactNode;<br> errorMessageClassName?: string;<br> value: string;<br> name: string;<br> id: string;<br> disable?: boolean;<br> placeholder: string;<br> touched: boolean | undefined;<br> error: string | undefined;<br> handleFocus?: () =&gt; void;<br> handleBlur: {<br>  (e: React.FocusEvent&lt;any, Element&gt;): void;<br>  &lt;T = any&gt;(fieldOrEvent: T): T extends string ? (e: any) =&gt; void : void;<br> };<br> handleChange?: (e: React.ChangeEvent&lt;any&gt;) =&gt; void;<br> handleKeyDown?: (event: React.KeyboardEvent&lt;HTMLInputElement&gt;) =&gt; void;<br>};<br><br>const Input: React.FC&lt;FormTextInputProps&gt; = ({<br> refElement,<br> label,<br> className,<br> containerClassName,<br> labelClassName,<br> inputContainerClassName,<br> child,<br> errorMessage,<br> errorMessageClassName,<br> inputType = &quot;text&quot;,<br> handleBlur,<br> name,<br> value,<br> errorChild,<br> handleKeyDown,<br> handleChange,<br> id,<br> touched,<br> error,<br> disable,<br> placeholder,<br> handleFocus,<br> ...props<br>}) =&gt; {<br> return (<br>  &lt;div<br>   ref={refElement}<br>   className={`w-full font-inter flex flex-col items-start gap-y-2 ${containerClassName}`}&gt;<br>   {label &amp;&amp; (<br>    &lt;label<br>     className={`${formLabelStyle} ${labelClassName}`}<br>     htmlFor={id || name}&gt;<br>     {label}<br>    &lt;/label&gt;<br>   )}<br>   &lt;div className={`relative w-full ${inputContainerClassName}`}&gt;<br>    &lt;input<br>     id={name}<br>     name={name}<br>     type={inputType}<br>     onChange={handleChange}<br>     onBlur={handleBlur}<br>     onFocus={handleFocus}<br>     disabled={disable}<br>     placeholder={placeholder}<br>     onKeyDown={handleKeyDown}<br>     value={value}<br>     {...props}<br>     className={` ${<br>      touched &amp;&amp; error<br>       ? &quot;border-[#BC0016]&quot;<br>       : &quot;border-primary-grey &quot;<br>     } ${value &amp;&amp; &quot;border-secondary-blue&quot;} ${className}`}<br>    /&gt;<br>    {child}<br>   &lt;/div&gt;<br>   {touched &amp;&amp; error ? (<br>    &lt;&gt;<br>     {errorMessage || (<br>      &lt;div className=&quot;flex flex-row items-center gap-x-2 text-[red] ease-in duration-200 text-xs&quot;&gt;<br>         &lt;p&gt;{error}&lt;/p&gt;<br>       &lt;/div&gt;<br>     )}<br>    &lt;/&gt;<br>   ) : null}<br>   {errorChild}<br>  &lt;/div&gt;<br> );<br>};<br><br>export default Input;</pre><p>The code above is the boilerplate for our global input component, which we’ll be using for our password field. It can also be extended for other input use cases like ‘text’ and ‘number’ fields, but for now, our focus is on the password field. Feel free to extend or modify the code to suit your taste and style preferences.</p><p>We’ll start by creating our password constraints, which is just a list of rules put in place for every user to follow when they’re creating a password.</p><pre>export const passwordConstraintContent: {<br> id: number;<br> name: string;<br> message: string;<br>}[] = [<br> {<br>  id: 1,<br>  name: &quot;minLength&quot;,<br>  message: &quot;Password must be at least 10 characters&quot;,<br> },<br> {<br>  id: 2,<br>  name: &quot;lowercase&quot;,<br>  message: &quot;Must contain at least one lowercase letter&quot;,<br> },<br> {<br>  id: 3,<br>  name: &quot;uppercase&quot;,<br>  message: &quot;Must contain at least one uppercase letter&quot;,<br> },<br> {<br>  id: 4,<br>  name: &quot;number&quot;,<br>  message: &quot;Must contain at least one number&quot;,<br> },<br> {<br>  id: 5,<br>  name: &quot;special&quot;,<br>  message: &quot;Must contain at least one special character&quot;,<br> },<br>];</pre><p>Let’s also create our validation schema using Yup. By the way, you can use any validation schema of your choice. I just like Yup, and I’ve also been using Zod for a while now. I find it very interesting and good for multiple use cases. For the sake of this tutorial, I will be focusing on just the password field because that’s where our interest lies. So, our validation schema will just be specifically for our password field.</p><pre>import * as yup from &quot;yup&quot;;<br><br>export const signUpValidationSchema = yup.object().shape({<br> password: yup<br>  .string()<br>  .required(&quot;Password is required&quot;)<br>  .test(&quot;minLength&quot;, &quot;Password must be at least 10 characters&quot;, (value) =&gt;<br>   /^.{10,}$/.test(value),<br>  )<br>  .test(<br>   &quot;lowercase&quot;,<br>   &quot;Must contain at least one lowercase letter&quot;,<br>   (value) =&gt; /[a-z]/.test(value),<br>  )<br>  .test(<br>   &quot;uppercase&quot;,<br>   &quot;Must contain at least one uppercase letter&quot;,<br>   (value) =&gt; /[A-Z]/.test(value),<br>  )<br>  .test(&quot;number&quot;, &quot;Must contain at least one number&quot;, (value) =&gt;<br>   /\d/.test(value),<br>  )<br>  .test(<br>   &quot;special&quot;,<br>   &quot;Must contain at least one special character&quot;,<br>   (value) =&gt; /[!@#$%^&amp;*(),.?&quot;:{}|&lt;&gt;]/.test(value),<br>  ),<br>});</pre><p>The code above is our Yup validation schema for our form. It’s as simple as this: for every password strength rule, we’ll write a regular expression for it. For example, if we want to make sure the user has an uppercase character in their password, we’ll write a regex to check for it. Got it? I’m sure you do :)</p><p>Pay attention to the fact that each regex we wrote in our validation schema, contains the same unique name in each password constraint we wrote earlier as this will be important in our password strength hook.</p><p>Now, let’s create our custom hook for our password strength.</p><pre>export const useSignUpCriteria = (<br> setMatchedCriteria: React.Dispatch&lt;React.SetStateAction&lt;string[]&gt;&gt;,<br> values: {<br>   password: string;<br> }<br>) =&gt; {<br> useEffect(() =&gt; {<br>  // Update the matched criteria array dynamically<br>  const updatedCriteria = [];<br><br>  // Check if the password value is empty<br>  if (values?.password?.trim() === &quot;&quot;) {<br>   setMatchedCriteria([]);<br>   return;<br>  }<br><br>  //Add &quot;minLength&quot; to criteria if the value&#39;s length exceeds 9<br>  if (/^.{10,}$/.test(values?.password)) {<br>   updatedCriteria.push(&quot;minLength&quot;);<br>  }<br><br>  // Add &quot;number&quot; to criteria if the value contains a number<br>  if (/\d/.test(values.password)) {<br>   updatedCriteria.push(&quot;number&quot;);<br>  }<br><br>  // Add &quot;lowercase&quot; to criteria if the value contains a lowercase letter<br>  if (/[a-z]/.test(values.password)) {<br>   updatedCriteria.push(&quot;lowercase&quot;);<br>  }<br><br>  // Add &quot;uppercase&quot; to criteria if the value contains an uppercase letter<br>  if (/[A-Z]/.test(values.password)) {<br>   updatedCriteria.push(&quot;uppercase&quot;);<br>  }<br><br>  // Add &quot;special&quot; to criteria if the value contains a special character<br>  if (/[!@#$%^&amp;*(),.?&quot;:{}|&lt;&gt;]/.test(values.password)) {<br>   updatedCriteria.push(&quot;special&quot;);<br>  }<br><br>  // Update the matchedCriteria array<br>  setMatchedCriteria(updatedCriteria);<br> }, [values.password]);<br>};</pre><p>I tried to make this custom hook as self-explanatory as possible, but if there’s too much going on and you can’t seem to place your finger on it, that’s not a bad thing. Learning is part of the journey. The code above is a custom hook which takes in two parameters.</p><ul><li>setMatchedCriteria: this is an array state of strings (This holds all the constraints that fails when we do the regex validation for the password value)</li><li>value: this is the actuall password input value. With our use effect, which runs everytime password value changes.</li></ul><p>I know what you might be thinking already: that our custom hook does almost the same thing as our Yup validation. Well, yes, it sort of does, but in a slightly different way. Hear me out first. Imagine we had other fields like username and email that we also want to validate. We’d be putting them inside our Yup validation schema as well. Think of it like a 2FA for the password field alone. Formik does its own validation together with other input fields in the form, and our custom hook does the same too. But our custom hook stores these constraints in an array state which we passed as a parameter and we’ll be making use of that state later. :) See, I told you to hear me out.</p><p>Moving on we’ll create our form using useFormik hook where we pass our initialValue and validationSchema which we assigned the Yup validation schema we created earlier to it.</p><pre>&quot;use client&quot;;<br>import { FormikHelpers, useFormik } from &quot;formik&quot;;<br>import React, { useRef, useState } from &quot;react&quot;;<br>import { passwordConstraintContent } from &quot;../../../../../contents&quot;;<br><br>type Props = {};<br><br>const SignUp = (props: Props) =&gt; {<br> const [matchedCriteria, setMatchedCriteria] = useState&lt;string[]&gt;([]);<br> const [userTriesToSubmit, setUserTriesToSubmit] = useState&lt;boolean&gt;(false);<br> const refElement = useRef(null);<br><br> const initialValue: SignUpFormType = {<br>  password: &quot;&quot;,<br> };<br><br> const formik = useFormik({<br>  initialValues: initialValue,<br>  validationSchema: signUpValidationSchema,<br>  onSubmit: (value: SignUpFormType, formikHelper) =&gt; {},<br> });<br><br> const { values, handleChange, handleBlur, errors, touched } = formik;<br><br> useSignUpCriteria(setMatchedCriteria, formik?.values);<br><br>return (<br>  &lt;div&gt;<br>      &lt;form onSubmit={handleSubmit}&gt;<br>        &lt;div className=&quot;flex flex-col w-full gap-y-3&quot;&gt;<br>           &lt;Input<br>              value={values?.password}<br>              id={values?.password}<br>              name={&quot;password&quot;}<br>              handleChange={handleChange}<br>              handleBlur={handleBlur}<br>              touched={touched?.password}<br>              error={errors?.password}<br>              inputType={&quot;password&quot;}<br>              placeholder=&quot;Enter password&quot;<br>              label=&quot;Password&quot;<br>             /&gt;<br>             &lt;div className=&quot;font-satoshi flex flex-col gap-y-3&quot;&gt;<br>                {passwordConstraintContent?.map((child, index) =&gt; (<br>                  &lt;div<br>                    className={`text-sm flex flex-row items-center gap-x-2 ${<br>                     matchedCriteria?.includes(child.name)<br>                      ? &quot;text-primary-green&quot;<br>                      : userTriesToSubmit &amp;&amp;<br>                         !matchedCriteria?.includes(child.name)<br>                       ? &quot;text-[red]&quot;<br>                       : &quot;text-secondary-grey&quot;<br>                    }`}&gt;<br>                    &lt;p&gt;{child.message}&lt;/p&gt;<br>                   &lt;/div&gt;<br>                )}<br>             &lt;/div&gt;<br>          &lt;/div&gt;<br>      &lt;/form&gt;<br>  &lt;/div&gt;<br>)</pre><p>calling the useSignUpCriteria hook we created ealier we pass in the 2 arguments it takes which are setMatchedCriteria set state and formik.value which is our password value. The code beneth the &lt;Input /&gt; component is where we let the user know when their password passes each constraint.</p><p>We looped throught passwordConstraintContent which we created ealier as well and do a simple check if the constraint name field is included in ourmatchedCriteria array state if that returns true, tailwind css changes the text color to green else turns it to red.</p><p>By combining these elements, we’ve not only improved our application’s security but also created a more user-friendly experience. Remember, strong passwords are a crucial first line of defense in cybersecurity, and tools like this help users create better passwords without sacrificing usability.</p><p>I hope this tutorial has been helpful in showcasing how to implement a robust password strengthener. Feel free to adapt and expand upon these concepts in your own projects. Stay secure, and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0962e376cfcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Security for Beginners Part 2: UserDetailsService and Database Communication]]></title>
            <link>https://medium.com/@adigunolamide200/spring-security-for-beginners-part-2-userdetailsservice-and-database-communication-3661832624f9?source=rss-f04c64483c8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3661832624f9</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Adigun Olamide]]></dc:creator>
            <pubDate>Tue, 10 Oct 2023 01:13:13 GMT</pubDate>
            <atom:updated>2023-10-10T01:13:13.669Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, and welcome back to the second part of this blog series! I hope you found the first installment enjoyable and informative. If, by any chance, you’ve landed directly on this second part of the series, I would strongly recommend reading the first part. This will ensure you have a solid understanding of what we’ve been discussing and building upon. You can find the link to the first part <a href="https://medium.com/@adigunolamide200/spring-security-for-beginners-part-1-introduction-to-user-modeling-c96ad1960415">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S92L6fbwmHifFhhzQTQl6Q.png" /><figcaption>Photo credit: <a href="https://www.toptal.com/">https://www.toptal.com/</a></figcaption></figure><p>I know what you might be thinking, this is the same big, intricate images illustrating the flow and internal workings of Spring Security. But let me emphasize just how crucial diagrams like this are, particularly for software engineers.</p><p>As you progress in your career, you might find yourself building intricate solutions and needing to explain them to non-technical stakeholders, such as your boss. In such situations, diagrams like the one above and UML diagrams become invaluable tools. So, I strongly recommend taking the time to familiarize yourself with the diagram above.</p><p>When you take a look at our Spring Security flow illustration diagram, you’ll notice a section on the right labeled User Details Service. This is where we’ll begin our exploration. We’ll start by understanding this section and then gradually move on to the “Security filter” section of the diagram.</p><p>Now, let’s get into it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36cef1b41ce35ae589966f5ca6c6fcb3/href">https://medium.com/media/36cef1b41ce35ae589966f5ca6c6fcb3/href</a></iframe><p>The code above introduces a Spring Security interface called UserDetailsService. Within this interface, there’s a method called loadUserByUsername, which takes a username as its parameter. The method’s purpose is quite self-explanatory, but I’d like to draw your attention to something noteworthy: the returned data type, UserDetails.</p><p>If you’ve been following this tutorial from <a href="https://medium.com/@adigunolamide200/spring-security-for-beginners-part-1-introduction-to-user-modeling-c96ad1960415">Part 1</a> (which I truly hope you have), you’ll recall that we discussed the UserDetails interface and implemented it in a class UserDetailModel. It provides a foundational structure that Spring Security expects us to adhere to in order to comprehend and interact with our users’ information.</p><p>How do we utilize this UserDetailsService interface, implement it within a class, and employ the loadUserByUsername method to retrieve our user data and pass it into the constructor of the UserDetailModel class which implements UserDetails interface? These are excellent questions, and we’ll address them one by one.</p><p>Let’s start by addressing the loadUserByUsername method. It’s named as such because it implies that we want to retrieve user data. Now, where do we typically store user data? In a database, of course! I won’t dive into database specifics because I assume you all have a basic understanding of Spring Boot. This prerequisite involves persisting data in a database before delving into Spring Security. This order of learning can provide you with a fundamental grasp of essential concepts like project structure, dependency injection, database connectivity, and the Controller -&gt; Service -&gt; Repositorystructure, among others. Moving on.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7394fdae704fdb6d6771a6875399fa1/href">https://medium.com/media/c7394fdae704fdb6d6771a6875399fa1/href</a></iframe><p>The code above is a Spring repository class that implements the UserDetailsService interface for user authentication purpose we’ll be using Spring boot data jdbc to communicate with our database. If you’d like to know what authentication means, I made a good example of authentication and authorization in the part 1 series of this blog you can find it <a href="https://medium.com/@adigunolamide200/spring-security-for-beginners-part-1-introduction-to-user-modeling-c96ad1960415">here</a> I’m sure you’ll like it. So back to Spring repository let me explain what is going on in code above.</p><p>Line 4: We defined a private logger using the SLF4J framework, which is commonly used for logging messages and errors during the runtime of an application. This logger will be used to record log messages, which can be helpful for debugging and monitoring the application.</p><p>Line 6: We declared a private class property named jdbcClient of type JdbcClient. This property will hold an instance of the JdbcClient class, and will be used for database interactions.</p><p>Lines 8–12: Our class constructor takes a single argument of type JdbcClient. This constructor is used for dependency injection, because constructor based dependency injection is better :) and which means that an instance of JdbcClient is injected into the UserRepository class when it&#39;s created or initialized. This allows the UserRepository to work with a JdbcClient without creating a new instance of it within the class.</p><p>Line 22–45: Our loadUserByUsername is annotated with @Override annotation indicating that it overrides a method from the UserDetailsService interface. inside this method there’s a try-catch block.</p><p>In the tryblock:</p><p>we use the jdbcClient property to execute our SQL query to retrieve a user from the database based on the provided username.</p><p>The query is parametrized using the :username placeholder and the actual value is set using .param(&quot;username&quot;, username).</p><p>It uses .query(UserModel.class) to map the result to an instance of the UserModel class. It indicates that the query result should be treated as a UserModel object.</p><p>The result of the query is stored in an Optional&lt;UserModel&gt; named user.</p><p>It uses .optional() to convert the query result into an optional, which allows for handling the case where the user might not exist.</p><p>After retrieving the user, it checks if it exists using user.orElseThrow(...). If the user is not found (i.e., the optional is empty), it throws a UsernameNotFoundException with the message &quot;Username and password not found.&quot;</p><p>If the user is found, it creates a UserDetailModel instance using the found user and returns it. If you’re wondering where did UserDetailModel comes from? please check Part 1 of this blog series, where we discussed modeling our user <a href="https://medium.com/@adigunolamide200/spring-security-for-beginners-part-1-introduction-to-user-modeling-c96ad1960415">here</a> .</p><p>In thecatch block:</p><p>In case of a DataAccessException (likely related to database issues), it catches the exception, logs an error message using the logger, and rethrows it as a DatabaseDataAccessException normally, we should be handling more exceptions so as to avoid what is known asexception swallowing but for the sake of this tutorial we’ll catch just this.</p><h3>The End:</h3><p>Thank you for reading, folks. I trust you’ve enjoyed this second installment of our blog series on Spring Security, finding it both interesting and informative. In the next part, we’ll explore the diagram section labeled ‘Authentication Provider,’ where our authentication logic resides. I encourage you to stay with me for the next chapter of our journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3661832624f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Security for Beginners Part 1: Introduction to User Modeling.]]></title>
            <link>https://medium.com/@adigunolamide200/spring-security-for-beginners-part-1-introduction-to-user-modeling-c96ad1960415?source=rss-f04c64483c8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c96ad1960415</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Adigun Olamide]]></dc:creator>
            <pubDate>Sun, 08 Oct 2023 18:20:03 GMT</pubDate>
            <atom:updated>2023-10-10T01:14:26.273Z</atom:updated>
            <content:encoded><![CDATA[<p>The diagram below provides a comprehensive overview of Spring Security’s internal workings and flow. I recommend familiarizing yourself with it, as we will refer to this diagram throughout the blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwCha1OJkXTs-9kJ9C6Seg.jpeg" /><figcaption>Photo credit: <a href="https://www.toptal.com/">https://www.toptal.com/</a></figcaption></figure><p>Starting with Spring Security was a bit challenging for me when I first delved into it. There was so much to grasp and understand. However, my journey became more manageable with the assistance of an incredible book called “Spring Security in Action” by Laurentiu Spilca, along with some enlightening blog posts. This experience inspired me to create this blog post series tailored for absolute beginners taking their first steps with Spring Security. I understand that it can seem overwhelming, but don’t let that discourage you. In this series, I will explain Spring Security in as much detail as possible, so let’s dive right in.</p><p>Let’s begin by following a bottom-up approach, where we’ll start with the code, logic, and implementation that are not depicted in the diagram above. We’ll gradually work our way up to the diagram sections and implementations trust me this will be fun.</p><h4>User</h4><p>Yes, every request is initiated by something, whether it’s a bot, an actual user, a scheduled call, or any other trigger. Just like any application, we need users to interact with it. Assuming you’re already familiar with Spring Boot because this tutorial will focus exclusively on Spring Security, let’s proceed to model our user. Our user will be a simple one with essential properties such as username, email, password, and role. Without further ado, let’s start modeling our user.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d514931fc43e8eb0ee541599603bbba9/href">https://medium.com/media/d514931fc43e8eb0ee541599603bbba9/href</a></iframe><p>Now that we’ve successfully modeled a basic user DTO that we plan to persist in our chosen database, we can dive into the intricate world of Spring Security’s internal components. When we discuss security in software development, two essential terms you’ll frequently encounter are Authentication and Authorization. These concepts play a crucial role in ensuring the security of your software.</p><p><strong>Authentication:</strong> Authentication is the process through which a user is required to provide all the necessary security information before being granted access to the system. Think of it like passing through airport security: before you can board a plane, you must show your passport, have your luggage scanned, and undergo various security checks. In software, authentication is a similar concept, it’s the initial verification step to confirm the user’s identity.</p><p><strong>Authorization:</strong> Authorization, on the other hand, comes into play after the user has been authenticated and is granted access to the system. However, it doesn’t mean the user has unrestricted access. It’s about determining what specific actions or areas of the system a user is allowed to access. Returning to our airport analogy, imagine you’ve successfully passed through all the authentication checks and are about to board your flight. If you have an economy class ticket, you won’t be allowed to access the first-class section. The flight attendants will stop you (unauthorized) because you don’t have the necessary authorization to enter that area. Similarly, in software, authorization defines what a user can and cannot do within the system. You may be allowed to use certain features but restricted from accessing confidential or restricted parts of the application, such as administrative functions or sensitive data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5af7f1e367d3347f45ceb15045b5b6eb/href">https://medium.com/media/5af7f1e367d3347f45ceb15045b5b6eb/href</a></iframe><p>The code above represents a Spring Security interface called “GrantedAuthority.” As developers, we use this interface to inform Spring Security about the role or authority that a user possesses. You might have noticed that the “getAuthority()” method returns a single ‘String.’ You might wonder, ‘What if the user has more than one authority?’ That’s an excellent question, and we’ll address it in the next interface I’m about to introduce.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64442661005c4b627944617e01583001/href">https://medium.com/media/64442661005c4b627944617e01583001/href</a></iframe><p>This is the “UserDetails” interface, which, like many other Spring Security interfaces, can be extended to suit your specific requirements. It provides a fundamental structure that Spring Security expects us to follow in order to understand and interact with our user’s information. This is a prime example of pure encapsulation, and you’ll soon see why I find it amazing.</p><p>Spring Security simply asks, ‘Hey developer, I need a way to interact with your user and perform various operations.’ While different applications may have different user object models, one thing remains consistent: a user must have a username, a password, and authorities. As I delved into this, I was truly amazed at how powerful the four pillars of Object-Oriented Programming (OOP) can be. The Spring Security team has done an exceptional job. Now, let’s explore each of these methods one by one.</p><p><strong>getAuthorities():</strong> This method is responsible for returning all the authorities granted to the user, which Spring Security relies on for Authorization purposes. Take note of the method&#39;s return type; it makes use of generics. While I won&#39;t delve into generics in this post, you can always explore this topic separately. The method’s return type is defined as “Collection&lt;? extends GrantedAuthority&gt;”. If you recall from our previous discussion of the &#39;GrantedAuthority&#39; interface, it included a method called &quot;getAuthority” that returns a &#39;String.&#39; Now, in this method&#39;s return type, we&#39;re utilizing that &#39;String&#39; type. Just keep this in mind for now, as when we start implementing it, it will all come together and make sense.</p><p><strong>getPassword():</strong> This method returns the user’s password.</p><p><strong>getUsername():</strong> This method returns the user’s username.</p><p><strong>isAccountNonExpired():</strong> This method returns true or false to indicate whether the user’s account has expired.</p><p><strong>isAccountNonLocked():</strong> This method returns true or false to indicate whether the user is locked or not.</p><p><strong>isCredentialsNonExpired():</strong> This method returns true or false to indicate whether the user’s credentials, like the password, have expired.</p><p><strong>isEnabled():</strong> This method returns true or false to indicate whether the user is enabled or not.</p><p>Now that we’ve discussed the purpose of these interface methods, as with any other interface, we’ll need to implement the “UserDetails” interface. We’ll achieve this by creating a class named “UserDetailsModel”.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b390965fc9eba223f8b741e2f0072fb/href">https://medium.com/media/8b390965fc9eba223f8b741e2f0072fb/href</a></iframe><p>The code above represents our “UserDetailsModel,” which we’ve created by implementing the Spring Security “UserDetails” interface. As is customary when implementing interfaces, we must provide implementations for each method defined in the interface. I’m sure you’re aware of this requirement.</p><p>By implementing these methods within a separate class, we have the flexibility to pass our “UserModel” into the constructor of our “UserDetailsModel.” This approach helps maintain clean and tidy code organization.</p><h4>The End:</h4><p>Thank you for reading, folks. I hope you’ve found this first part of the blog series on Spring Security interesting and informative. <a href="https://medium.com/@adigunolamide200/spring-security-for-beginners-part-2-userdetailsservice-and-database-communication-3661832624f9?postPublishedType=initial">In the next installment, we’ll dive into the diagram above, exploring the internal workings and flow of Spring Security.</a> It promises to be an exciting journey, and I look forward to seeing you in the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c96ad1960415" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>