Skip Navigation

silas

@silas.lemmy.eco.br.ap.tdpl.io

2 Posts0 Comments0 Memberships

Joined November 2026

  • Using sed to match regexp patterns in a file with a fixed string (not the other way around)

    Hi there! Usually, sed can be used in different ways, but most of the time we use it to match lines in a file against a fixed regexp. Some examples: This replaces ocurrences of regexp for "foo":

     
    sed 's/regexp/foo/g' < myfile

    This prints all lines that have "foo", but will change the first "o" in the line for an "a":

     
    sed -n '/foo/s/o/a/p' < myfile

    and so on... But I tried to do a different thing, with no success: can I pass to sed a file with a bunch of regular expressions and test them against a fixed string? I tried to play with pattern space, hold space, with no success. It just seems impossible to use them (which would be the closest to "variables") in search commands. I know sed is Turing complete, but using it that way would maybe require to implement a regexp engine from scratch? Thanks!

  • Spring Security styles for enabling authentication

    Hello there. I'm writing a simple REST API using Spring Boot and I just added basic HTTP authentication in it. I'm currently using Spring Boot 3.1.5 and Spring Security 6.1.5. There are different instructions on the web about how to correctly setup basic HTTP authentication for web requests, I believe they differ according to the Spring Security version. It seems that latest guides use implementations of the UserDetails interface, which I found rather confusing, as it is not clear for me how exactly the framework uses that. Instead, I found much easier and clear to write my own class that inherits from AuthenticationProvider and override its authenticate() method to do all fancy things for me, including checking and setting user roles. I'd like to ask you if there is any drawback working with AuthenticationProvider that I cannot see right now, instead of newest documentation, that doesn't seem to just use default AuthenticationProvider. Thanks!