gpb

gpb

A friend is creating a private API Gateway / Service, written in GO.

I am creating an Elixir Client, a simple web Phoenix web-app that will allow a few users to login and consume these API services.

We want to limit access to this private API to just our Elixir client for now, in as secure a way as possible.

Our thinking so far is:

*Use an API-key to limit access to only the Elixir Client. The intent is to prevent other external client-apps from attempting to use the API (for now).

*When a user logs in successfully, the API passes back a token or starts a session.

*Onwards, we will use a token or session for authentication for this user.

My question: after a successful login, is it superfluous to continue passing the API-key? Or, is it simply necessary by design?

Showing Posts 1 to 6

dwahyudi

dwahyudi

RESTful should be stateless.

I think you should always pass the API-key. Just make sure that it is really really secret.

Some people likes to create session on API-endpoint. I personally don’t.

OvermindDL1

OvermindDL1

If it is actually an API, cookie-less, then always pass in the API key, always. If you have cookies then use the cookie to store it instead after a login. Most API’s don’t support cookies though and always passing in the key is generally done.

For note, always passing the ‘same’ key is generally a security issue. Generally you get an initial key, pass it in on the first request of whatever you need to do, and you get a new single-use key back, and repeat with that one. That tends to be more irritating to use though so most don’t actually do that as it requires client-local storage too.

gpb

gpb OP

Thanks for that. We’re still in research mode and every bit helps!

I’m curious about the definition of a “pure API”. We intend that the main job of the API will be to return JSON data.

It does appear most APIs do not support cookies. I’m puzzled as to whether this is just to make things more convenient for the API architecture, or whether there is a strong anti-cookies philosophy involved.

Is it simply just more performant/convenient to use tokens (opaque or JWT) to protect API endpoints?

OvermindDL1

OvermindDL1

Eh the definition is fuzzy, but I generally use it in such a way that each request is entirely stateless.

I think it’s just because adding cookies complicates ‘some’ client libraries (not so much anymore, but back in the day it definitely did).

Not at all, if anything cookies are more performant. I really think it’s just because so many older http client libraries didn’t have cookie support (but as stated, nowadays that’s not really an issue anymore, so its an old holdover).

CptnKirk

CptnKirk

Why would a Cookie header value be more performant than say an Authorization header value or a request param?

You also open yourself up to many potential security holes depending on how your HTTP client is used elsewhere within the system.

This Wikipedia entry has a good rundown of the more common gotchas. I’d stick with a generated API token managed outside of a cookie myself.

OvermindDL1

OvermindDL1

A cookie would be about the same as an authorization header for that, but as a request param not as much (phoenix has to parse those out in a different way, plus you don’t want cache’rs to cache secure parameters). Passing it in via a header is fine though, via a parameter or javascript encoding or so is slower (but not enough to really matter).

As for the issues, just keep doing the same things, invalidate it on every request and issue a new one (which is much easier for the client to handle then if it’s a cookie as then they don’t need to do anything special beyond cookie things).

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews