Hey everyone, I am trying to implement a React SP...
# general
v
Hey everyone, I am trying to implement a React SPA and a Go backend with ory, could you give me some starting points either in the docs or a tutorial since I am a bit lost with all the documentation I just read
b
what part of auth are you wanting to start wityh?
I picked up Kratos (currently all within a docker-compose) and have a good integration with a Vue/Nuxt3 app
v
Basically I want to a do a quick POC where I log in from my React app and then send a simple get request to my go app, and I expect that I can't do unauthenticated apps to the go api
Also I will be not be self hosting myself
b
so you can probably skip the whole BE setup then. the
@ory/client
and
@ory/kratos-client
libs are great and all Typed out
v
Hmm, how will I protect unauthenticated users from hitting the api
This is what's confusing me
b
ahhh I've not done that bit in my app yet,, however I think I have a grasp of how it could work...
v
Yeah the front end seems pretty straight forward, just this backend part is confusing a little
b
I'm thinking I'm going to issue the app with a JWT,, since I'll know the JWT secret that ory will use I can use any JWT library in my API to auth it
that's one way
v
Hmm so no need for any Ory libraries installed in my go app ?
I also have roles on my app so that is a bit confusing
b
JWT can support roles IIRC
you jsut add the additional data of a role,, it could be anything. alternatively, once you've confirmed and decoded the JWT you can lookup the user ID as its encrypted within the token
v
Is the lifetime also configurable
And does it use refresh tokens to generate a new access token every few mins ?
b
v
Seems trivial
Thank you for all your input
You saved me a bunch of time
b
no worries.. JWT is jsut one way,, and i believe you can encode whatever you like in there... btw your backend will have to check the ttl, quick google gave this to check the claim on the token...
Copy code
ttl := 60 * time.Second
myClaims["exp"] = time.Now().UTC().Add(ttl).Unix()
but with Ory's session to JWT and a good JWT go lib you should be good to go
v
Yep as for this part I've done it very often
Just wondered how to achieve it with ory
b
gun fingers
d
Hi @victorious-plastic-3087, you could also setup Ory Oathkeeper with Authenticators : https://www.ory.sh/docs/oathkeeper/pipeline/authn