Khanashima / study-serverless

0 stars 0 forks source link

Auth0とLambdaAuthorizerオーソライズで認証 #18

Open Khanashima opened 1 year ago

Khanashima commented 1 year ago

https://dev.classmethod.jp/articles/lambda-authorizer-verify-token-from-auth0/ https://www.serverless.com/examples/aws-node-auth0-custom-authorizers-api https://github.com/arielweinberger/serverless-auth0-authorizer https://levelup.gitconnected.com/sls-auth0-go-34dfe5fab0b

superherobtf1985 commented 1 year ago

フロント側って何か使えるライブラリありますか?

vfjhanashima commented 1 year ago

@superherobtf1985 https://nuxt.com/modules?category=Security

https://nuxt.com/modules/nuxt-authはどうでしょうか? nuxt3に対応しています。

superherobtf1985 commented 1 year ago

ありがとうございます!

superherobtf1985 commented 1 year ago

@Khanashima sidebase/nuxt-authの認証って使えてますか? Auth0でできないのでGitHubの認証(ドキュメントのGetStartedの手順)をやってみたのですが、 それもうまくいかず、、、 ログインボタンを押すと404になります。 (Auth0の場合は「message: 'only valid absolute URLs can be requested'」というエラーが出ます。

以下はGitHubで試したログです。(<>は実際の値を隠してます)

[next-auth][debug][GET_AUTHORIZATION_URL] { 12:42:03 url: 'https://github.com/login/oauth/authorize?client_id=<client_idが入ってます>&scope=read%3Auser%20user%3Aemail&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fcallback%2Fgithub&state=<省略>', cookies: [ { name: 'next-auth.state', value: '<cookieの値がはいってます>', options: [Object] } ], provider: { id: 'github', name: 'GitHub', type: 'oauth', authorization: { url: 'https://github.com/login/oauth/authorize', params: [Object] }, token: { url: 'https://github.com/login/oauth/access_token', params: {} }, userinfo: { url: 'https://api.github.com/user', request: [AsyncFunction: request] }, profile: [Function: profile], style: { logo: '/github.svg', logoDark: '/github-dark.svg', bg: '#fff', bgDark: '#000', text: '#000', textDark: '#fff' }, idToken: false, checks: [ 'state' ], clientId: '<client_idが入ってます>', clientSecret: '<clientSecretが入ってます>', signinUrl: 'http://localhost:3000/api/auth/signin/github', callbackUrl: 'http://localhost:3000/api/auth/callback/github' } }

vfjhanashima commented 1 year ago

Auth0でできました。 ログインまでできています。トークンもクッキーで保存されていました。 色々試行錯誤しました。 メールしました。

superherobtf1985 commented 1 year ago

なんと、、ありがとうございます。 明日確認します!

vfjhanashima commented 1 year ago

自分のローカル環境であります。

superherobtf1985 commented 1 year ago

本当ですね。できてそうです。 ちなみにユーザーの追加削除をおこなえるかって既に見えてたりしますか?

vfjhanashima commented 1 year ago

@superherobtf1985 新規登録はありそうですが、まだ未検証です。 ユーザー削除はないです。 ログインユーザーは管理画面から作成しました。

スクリーンショット 2023-04-02 15 36 55
vfjhanashima commented 1 year ago

@superherobtf1985 会員登録は上記のsign upからできました。

削除もユーザー側で対応でしょうか?

vfjhanashima commented 1 year ago

ユーザー削除は管理画面からはできます。

superherobtf1985 commented 1 year ago

削除も可能であれば組み込みたいという話でした