sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.11k stars 131 forks source link

Equivalent of SST 2.0 api-sst-auth-google in Ion? #371

Closed shen-lin closed 2 months ago

shen-lin commented 2 months ago

The closest example I could find is ion/examples/aws-auth.

The authentication process works successfully and I can call input.tokenset.claims() to retrieve user information.

But I have 3 remaining issues:

          const userClaim = input.tokenset.claims();
          const sessionToken = await session.create({
            type: "user",
            properties: {
              username: userClaim.sub,
              email: userClaim.email ?? "",
            },
          });

          const userClaimFromAccessToken = await session.verify(sessionToken);

Since I am not able to pass the token as set-cookie to client yet, I tested session.verify also inside async success(ctx, input). But it returned error "Error: No auth resource found".

By looking at the implementation in sdk/js/src/auth/session.ts, it seems create method can use AUTH_PRIVATE_KEY either from env var or linked Resource. But verify method only attempts to find public key from linked Resource value that has a publicKey property. Why the private key and public key are accessed quite differently?

const auth = Object.values(Resource).find((value) => value.publicKey);
thdxr commented 2 months ago

we are releasing auth more officially next week so you should hold off trying to use it until then

shen-lin commented 1 week ago

@thdxr Is Auth released now? I don't find it in the sst 3.0 documentation.

jayair commented 1 week ago

Nope not yet

shen-lin commented 1 week ago

@jayair Thanks for your reply. Do you have estimation when would it be ready?