lambda-authkun

command module
v0.0.0-...-1602a05 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2020 License: MIT Imports: 7 Imported by: 0

README

lambda-authkun

lambdaでもnginx_omniauth_adapterの認証使いたい!

つかいかた

mainのlambdaを

Auth:
  Authorizers:
    Authkun:
      FunctionPayloadType: REQUEST
      FunctionArn: arn:aws:lambda:ap-northeast-1:486414336274:function:lambda-authkun
      Identity:
        Headers:
          - Cookie
        ReauthorizeEvery: 0

のようにAuthorizer type REQUESTにする。

さらに、GatewayResponsesとして、

ACCESS_DENIED:
  StatusCode: 302
  ResponseParameters:
    Headers:
      Location: context.authorizer.location
  ResponseTemplates:
    application/json: $context.authorizer.msg

を設定します。 また、API Gatewayの制約でUNAUTHORIZEDの時にcontextを返したりできない? 気がするので、悲しい気持ちになります。これが誤っていたら教えてください……。

そして認証を受ける側に

import "github.com/nna774/lambda-authkun/adapter" して

http.HandleFunc("/_auth/callback", adapter.NewCallbackHandler("https://auth.dark-kuins.net/callback"))

/_auth/callback を生やす。

user info

omniauth_adapterの /test の返す以下の情報

  • x-ngx-omniauth-provider
  • x-ngx-omniauth-user
  • x-ngx-omniauth-info

の3つをそれぞれ

  • context.authorizer.provider
  • context.authorizer.user
  • context.authorizer.info

に入れて返します。

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL