Creando un microservicio de autenticación con Go, Gin, Twilio, Docker y Nginx - Parte I: Diseño

2025.01.22 22:18 mar-cial Creando un microservicio de autenticación con Go, Gin, Twilio, Docker y Nginx - Parte I: Diseño

Por un lado pienso que la autenticación debería ser lo más anónima posible. Deberías ser capaz de crear una cuenta para cualquier servicio y el usuario mismo proveer la información que desee...
Pero ya está OAuth. Qué fácil y qué buena experiencia solo picar botones y terminar con una cuenta creada en una base de datos. Cuánta conveniencia a cambio de entregar tu información, pero ¿de verdad es importante la información que entregamos?... No lo sé.
Mi problema eterno es decidirme entre ceder a las librerías ya existentes o implementar mi propia autenticación. Por qué yo pienso que debería ser más anónimo! Voy a hacer un paquete en Go que registre usuarios, haga login y logout. La unica opcion para crear una cuenta sera a traves de un numero celular. Me gustaria usar twilio para hacer 2mfa por que hace tiempo lei un feature de ellos. Decian que se puede confirmar el codigo enviado automaticamente en ciertos celulares. Lo peor que pueda pasar es que tengan que autocompletar el codigo de un uso directo desde su teclado. Despues de este simple y unico paso, los usarios ya contarian con una cuenta. Por que cuando cuentas cuentos cuenta cuantos cuentos cuentas. Si alguien me dice exactamente qué es lo malo de tener un paquete así en producción, abandono todo, utilizo OAuth y me voy a comer mi soya en una esquina oscura de mi depa.
Voy a empezar a hacer el servicio fuck it:
Parte 1: Diseño
1. Handler layer design
Más puesto que, sin embargo, a mi parecer, esto es básicamente todo lo que hace un servicio de autenticación. Una request que te registre, haga login o haga logout. Las funciones principales son las de AuthHandler. Tiene una dependencia bastante cabrona con Gin, pero pues no voy a hacer un web server desde cero tampoco.

type AuthHandler interface { Register(ctx *gin.Context) Login(ctx *gin.Context) Logout(ctx *gin.Context) } 
2. Service layer design
Ok, ahora aquí sí se tiene que pensar en lo que se tiene que hacer. El AuthService es el motor que dirige toda la operación. Aquí debería validar, procesar y autorizar la request del usuario para autenticarse. Tal vez puedo empezar con esa mentalidad a desarrollarlo:
type AuthService interface { Validate(ctx *context.Context) Process(ctx *context.Context) Authorize(ctx *context.Context) } 
No me convence... no me gusta... me parece que debería borrar ese service, hacer un RegisterService, LoginService y otro LogoutService... o tal vez la implementación de AuthHandler que tenga esos servicios como dependencias... muchas opciones... Así es, haré lo primero que dije. Y también aprovecharé para usar una técnica llamada interface composition y polymorphism, ya que voy a insertar esas interfaces en una sola interfaz. Tambien voy a insertar la interfaz para las cookies, igual, una simple interfaz que crea, lee, actualiza y descombula cookies:
type AuthService interface { RegisterService LoginService LogoutService CookieService } type RegisterService interface { UserCanRegister(ctx *context.Context) Register(ctx *context.Context) } type LoginService interface { UserCanLogin(ctx *context.Context) Login(ctx *context.Context) } type LogoutService interface { UserCanLogout(ctx *context.Context) Logout(ctx *context.Context) } type CookieService interface { Create(ctx *context.Context) Read(ctx *context.Context) Update(ctx *context.Context) Delete(ctx *context.Context) } 
Mucho mejor. Sentí que se me expandió el cerebro un poquito en esa última hazaña.
3. Repository layer design
Creo que voy a utilizar la misma lógica para el repository. Puesto a su vez que me parece, el AuthRepository se podría dividir en UserRepository y SessionRepository, y los dos realizan operaciones CRUD similares pero diferentes. Podría ir más a fondo, pero por ahora esto está bien.
type AuthRepository interface { UserRepository SessionRepository } type UserRepository interface { CreateUser(ctx *context.Context) ReadUser(ctx *context.Context) UpdateUser(ctx *context.Context) DeleteUser(ctx *context.Context) } type SessionRepository interface { CreateSession(ctx *context.Context) ReadSession(ctx *context.Context) UpdateSession(ctx *context.Context) DeleteSession(ctx *context.Context) } type CookieRepository interface { CreateCookie(ctx *context.Context) ReadCookie(ctx *context.Context) UpdateCookie(ctx *context.Context) DeleteCookie(ctx *context.Context) } 
Como probablemente se dieron cuenta, mi uso registrado y universal de *context.Context es abrumador. Pero ese contexto es clave para cancelar, hacerle timeout a requests y para la visibilidad del sistema. No le pasaré valores, lo prometo. Así como también probablemente se dieron cuenta, no puse nada más que *context.Context como parámetro. No es porque estoy enamorado del context. Lo que pasa es que me parece que primero tengo que regresarme al service layer, y al pensar en la implementacion, se me revelara como una vision cuales parametros son correctos para cada funcion en los servicios de AuthService. Para cerrar, naturalmente el primer paso de la implementacion nos lleva a crear data structures para organizar información. Entre menos data structures mejor, a mi parecer. Pero la estructura User me parece bastante necesaria. Cookie también.
type User struct { ID string `json:"id"` Phonenumber string `json:"phonenumber"` } 
Podria ahorrarme la definicion de la estructura SessionCooklie y solo usar http.Cookie. Voy a ahorrarme la deficion de la estructura SessionCookie y solo usar http.Cookie :).
Me parece bien cerrar este post definiendo esa estructura. En el siguiente post voy a empezar la implementacion. Diganme que piensan por favor, si lo desean. Si yo soy su loka, ustedes mi lokotron.
Aqui esta el repo por si a alguien le interesa.
submitted by mar-cial to programacion [link] [comments]


2025.01.22 22:18 FreemansAlive Need to replace charge port. How difficult?

The charge port on top for wired connection (not cradle) needs replacement. I watched a video that seems moderately challenging. Anyone here give this a run with recommendations to do or avoid? I can live without it, but it's a "nice to have" feature to have working again.
submitted by FreemansAlive to wiiu [link] [comments]


2025.01.22 22:18 Direct-Swordfish-642 How do I find a good workout plan? I'm currently focusing on hypertrophy.

I have one of my own, but I feel it might be poorly constructed, or not effective.
submitted by Direct-Swordfish-642 to workout [link] [comments]


2025.01.22 22:18 AndreaNewsHub Attracted attention for acts of violence and obliged to leave the country - This is what is known about the 28-year-old Afghan (orig.: Wegen Gewalttaten...) #WORLDNEWS #attention #Attracted #for #of #acts

Attracted attention for acts of violence and obliged to leave the country - This is what is known about the 28-year-old Afghan (orig.: Wegen Gewalttaten...) #WORLDNEWS #attention #Attracted #for #of #acts submitted by AndreaNewsHub to ItaliaBox [link] [comments]


2025.01.22 22:18 A_Lountvink Furry_irl

Furry_irl submitted by A_Lountvink to furry_irl [link] [comments]


2025.01.22 22:18 theviewhalfwaydown_ What does mine and my boyfriend’s fridge say about us?

What does mine and my boyfriend’s fridge say about us? submitted by theviewhalfwaydown_ to FridgeDetective [link] [comments]


2025.01.22 22:18 LocalLazyGuy The Anti-Redemption Arc, when the villain just keeps getting worse and worse

The Anti-Redemption Arc, when the villain just keeps getting worse and worse Note: This isn’t the villain doing worse things, it’s the villain actively developing into a worse and worse person in general. Sometimes it can start with them already being terrible people or it can start with them being completely innocent.
Homelander (The Boys) - He was already an awful person before the events of the series, however, as the show does on, we see him losing more of his sanity and giving into his impulses and desires more and more. We see him lose superiors who would usually rein him in, like Edgar and Stillwell, until eventually nobody can stop him and he’s just doing whatever he wants.
Light (Death Note) - He started out as a regular High School kid, albeit incredibly intelligent, but when he gets the Death Note, he starts playing God and punishing criminals through death. Eventually he moves onto killing any police or authorities who try to investigate him. By the end of the series, he’s gone fully insane and mad with his power and his ego pushed to its peak.
Salieri (Amadeus) - He starts out as a noble court composer for the Emperor. In the beginning, he idolises Mozart. Until he actually meets him and finds out that he’s nothing like he expected. He thought such a talented man would be just as refined as himself, but instead found a “giggling dirty-minded creature”. As the story goes on, Salieri finds himself hating Mozart and God more and more out of confusion as to why someone as immature as Mozart was given such remarkable talent and was so much better than Salieri. And by the end, plans to kill Mozart with his bare hands after stealing his music and claiming it as his own and playing it as Mozart’s funeral, as a final “fuck you” to God.
Walter White (Breaking Bad) - The most well known example of this trope I would say. He starts out as a desperate father trying to make money for his family as the threat of cancer looms over him. But as the story goes on, he loses sight of why he wanted to do it in the first place, and starts doing it for himself. For the thrill of it and the boost to his ego. “I did it for me. I liked it. I was good at it. And... I was really... I was alive.”
submitted by LocalLazyGuy to TopCharacterTropes [link] [comments]


2025.01.22 22:18 Oijrez What screams 'I am an ISFJ'?

submitted by Oijrez to isfj [link] [comments]


2025.01.22 22:18 rchilo 2 months today!

Feel amazing.
submitted by rchilo to sobrietyandrecovery [link] [comments]


2025.01.22 22:18 Aggravating_Funny978 Best (free) data for nutritional modelling of recipes?

Hi all,
I'm making a simple spreadsheet to help model recipe nutritional profiles (ingredients and the impact on nutritional values in the finished food), and I'm looking for data sources.
I've been taking data from the FDA fooddata website, but there seems to be inconsistency between types of data available and the values for numerous ingredients.
I don't intend to make FDA compliant nutritional facts label from this, just prototyping recipes and thinking about the impact of different ingredients.
I can live with it, but I was wondering if this is the best free source?
Thanks!
submitted by Aggravating_Funny978 to foodscience [link] [comments]


2025.01.22 22:18 banger030 M35 10% body fat, 6-7x gym per week, very healthy , no alcohol or processed foods. Testosterone levels dropped 30% in 9 months by 200 points to 500. Why?

submitted by banger030 to Testosterone [link] [comments]


2025.01.22 22:18 Square-Technology-52 I don't regret cashing out 😌

I don't regret cashing out 😌 submitted by Square-Technology-52 to sportsbetting [link] [comments]


2025.01.22 22:18 kal-ea Odemaris 🍑🍑

Odemaris 🍑🍑 submitted by kal-ea to OdemarisRuiz [link] [comments]


2025.01.22 22:18 wil24x7 🇺🇸- At least two students shot at Antioch High School, Nashville. The gunman reportedly shot himself. Moment of the shooting in the cafeteria in Antioch High School, Nashville, Tennessee.

🇺🇸- At least two students shot at Antioch High School, Nashville. The gunman reportedly shot himself. Moment of the shooting in the cafeteria in Antioch High School, Nashville, Tennessee. Article- https://www.cbsnews.com/news/antioch-high-school-shooting-tennessee/
submitted by wil24x7 to world24x7hr [link] [comments]


2025.01.22 22:18 AngloAmerican1941 Daily Sakuya Revival Day 472

Daily Sakuya Revival Day 472 submitted by AngloAmerican1941 to SakuyaGang [link] [comments]


2025.01.22 22:18 GurmanPlayz Apple Device (iPhone, Apple TV) not showing up in Finder

As well, Bluetooth isn’t working in terms of discovering devices on the Mac VM itself.
I am using an Intel laptop, MacOS 14.7.2 on VMWare 15.2.
Any help is greatly appreciated, thank you.
submitted by GurmanPlayz to macOSVMs [link] [comments]


2025.01.22 22:18 OutrageousPrice4664 Best courses for Botox/filler?

So I’m an RN (soon to be NP) and I’m trying to break into the world of aesthetics and thought doing a certification course might be a good idea?
I’ve heard of empire medical (not too many great reviews from what I’ve hear)?
I’ve also her of med aesthetics training?
Just looking for recommendations and what other people would suggest :)
submitted by OutrageousPrice4664 to nursing [link] [comments]


2025.01.22 22:18 RoohAfzaPapi_ IM rank list help - US IMG

US-IMG, recent graduate, ck 23x, 3 months usce, no pubs.
Priorities : location, no fellowship aspirations as of now.
Kindly give suggestions. I heard Long Island community hospital is toxic? I got really positive vibes from them though

  1. jfk raritan
  2. Atlanticare
  3. Long Island community hospital
  4. South East health Alabama
  5. Wright center
  6. Nuvance Vassar
  7. Brooklyn hospital center
  8. Unity health Arkansas
submitted by RoohAfzaPapi_ to IMGreddit [link] [comments]


2025.01.22 22:18 Phantom65946 There's no School quite like the Old School! 😎

There's no School quite like the Old School! 😎 It's always nice to get back onto ATS after playing different games. It's equally as refreshing when you decide to play around with a Old School but simple setup!
I've already posted this Truck in here before, it's my absolutely glorious Pete 379 Haterbilt that's made to be as Old School as possible. Beautiful truck but not something you can just get in and drive.
Up until today, I've been Hauling everything around in a standard SCS Trailer and while I have nothing against them, I decided to try out a Mod I found on Trucky and it's this - the Trailmobile SuperVan 90 Dry Van!
When paired with the Haterbilt, it just works so well and really suits the Old School vibe I was going for!
Can't wait to do a good few jobs with this setup once this job is done 😎
submitted by Phantom65946 to americantruck [link] [comments]


2025.01.22 22:18 Jack_E_Boi MSI Monitor Screen Glitch

MSI Monitor Screen Glitch I've had this monitor for a few years now but have been getting this glitch on it where the lower of the quarter of the screen isn't working properly, I know it isn't dead pixels as it still displays - just the wrong picture. It is happening on my PS5 and only happens on games that run 120fps (COD, Siege, Fortnite) while it doesn't happen on games that run at a lower refresh rate (Rust, ect...) Please someone help?
Not sure on the exact model of the monitor as I am trying to help a friend, it is MSI 144hz, 27" and has only been used on Playstation 4, and 5.
https://preview.redd.it/8jerno28emee1.jpg?width=900&format=pjpg&auto=webp&s=7a4cd8f349fb41f4046c6d4cb8bbf539916f0224
https://preview.redd.it/oijka7r8emee1.jpg?width=900&format=pjpg&auto=webp&s=fb0117a222c7341d983b97e073c71e2404be4f66
submitted by Jack_E_Boi to pcmasterrace [link] [comments]


2025.01.22 22:18 ctr12911 [WTS] - bcm, aero, magpul, surefire, Geiselle, Glock, leupold

Timestamp: https://imgur.com/a/yIKCaKc
Prices are shipped CONUS. PayPal FF and Venmo. NO NOTES

  1. Aero 30mm mount: - $50
  2. Surefire closed tine G$ nanocoated semi salty - $90
  3. Surefire closed tine G$ nanocoated extra salty - $80
  4. G$ FDE 1 inch sling - $40
  5. G$ H3 buffer with DD spring - $40
  6. Leupold dpp offset mount - $40
Add ons to the above or pick up 2 or more 1. Paintedpainted BCM grip - $10 2. Glock Gen 5 OEM Magwell - $8 3. Painted Magpul MOE stock - $18 4. Painted promag broomstick - $6
Dibs over PM
Thanks!
submitted by ctr12911 to GunAccessoriesForSale [link] [comments]


2025.01.22 22:18 nognoth Some time ago, I saw a post about pimping out the NA Horrified game by painting the minis. I was inspired.

Some time ago, I saw a post about pimping out the NA Horrified game by painting the minis. I was inspired. I loved how these turned out. And was surprised at the level of detail in the sculpts. Plus I never even noticed the deaths head design sculptedin the back of the Mothman.
submitted by nognoth to HorrifiedGame [link] [comments]


2025.01.22 22:18 Medicationist VA.gov no longer showing a “combat” designation ebenefits used to show?

VA.gov no longer showing a “combat” designation ebenefits used to show? VA.gov no longer showing “Combat” like ebenefits did?
For almost a decade my ebenefits said “PTSD-Combat”. Now on VA.gov, and on my diagnosis breakdown letter there is nothing about “combat”. Was there a glitch on ebenefits showing this when it wasn’t combat related, or now that it is transferred to VA.gov it no longer shows due to a glitch? The supervisor I spoke to knew nothing about this.
I applied for CRSC a few years ago, but I was denied for it not being combat related. I didn’t have a diagnosis breakdown letter when I applied for CRSC in 2022, at least I’m pretty sure. I served 9 years, 10 months and was medically retired at 30% DoD, and now I’m 100% VA. I was TDRL a year or two before permanently retiring. I talked to a supervisor at the VA 1800 #, but he didn’t really know too much on how “combat” is actually coded. A reddit post said the VA makes the determination, the supervisor said he believes DFAS makes the determination.
My VERA appointment is next week. Anyone know anything about “combat” no longer showing up? I called AF CRSC to call me back so I know why I was denied. It’s just weird how the VA used to say combat when it now doesn’t, and why I was denied CRSC as a “combat medic”. Does working through rocket and mortar attacks as well as climbing in Afghan ambulances that might have an IED not count as “combat”? I don’t understand how someone can qualify in a medical simulator but not the real thing if that’s the case.
submitted by Medicationist to VeteransBenefits [link] [comments]


2025.01.22 22:18 Live-Inflation-2394 Break / Breakup??

Hello everyone,
In a situation where my girlfriend and I were together for 3+ years but decided to break up/take a break for a month.
Out history is like all; it has its ups and downs. We broke up a year ago because I looked down on her and disrespected her to my friends. At the time, I thought it was okay, but I learned IT IS NOT OKAY TO DISRESPECT YOUR PARTNER EVER!!! We broke up but got back together after a month because I couldn't take it anymore. We were no contact for that month, but I ultimately reached out because I became suicidal, and I hated myself for doing that to her. We got back together after spending time together, but after a while, she told me she didn't know if she was happy in our relationship because she could not get over what I did.
We've been long distance for 6 months, seeing each other once a month (regular school breaks), and when we're together, it is heaven, but there are still some moments where she breaks down and tells me she can't get over what I did. Both of our schedules are incredibly busy and full. She informed me she feels like her part in the relationship is like "pouring water WITH an empty cup." It breaks my heart to hear that so I asked if she wanted to just finally call it.
We decided to go no contact for a month and see each other on Valentine's. She is hoping to get help and settle into her schedule and a new job as a nurse. We've agreed not to look for love or attention elsewhere, and I honestly trust her to not look for attention in anyone else as I will not either.
I'm scared she's going to decide that she's better off, and I'm hoping this break will give her time to think.
Any advice to help me get through this month???
submitted by Live-Inflation-2394 to BreakUps [link] [comments]


2025.01.22 22:18 a_Ninja_b0y Nonbinary ‘I Saw the TV Glow’ star changes name to Jack Haven | “I said I was using it in safe spaces,” Haven wrote. “Saman said use it in dangerous spaces."

submitted by a_Ninja_b0y to lgbt [link] [comments]


https://yandex.ru/