authfx

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FirebaseCheckModule = fx.Provide(
	func(
		l *zap.Logger,
		sSetting FirebaseSettingParams,
	) (out sfx.AuthMiddlewareResult, err error) {
		ctx := context.Background()
		c, err := firebase.NewApp(ctx, nil, option.WithCredentialsFile(sSetting.KeyFile))
		if err != nil {
			return
		}
		client, err := c.Auth(ctx)
		if err != nil {
			return
		}

		out.AuthMiddleware = &FirebaseAuthor{
			client:        client,
			unAuthMethods: map[string]struct{}{},
		}
		return
	},
)

FirebaseCheckModule is the firebase Auth module for grpc middleware

View Source
var FirebaseSettingsModule = fx.Provide(
	func() (out FirebaseSettingsResult, err error) {
		err = out.LoadFromEnv()
		return
	},
)

FirebaseSettingsModule is the Firebase settings module

View Source
var SupabaseCheckModule = fx.Provide(
	func(
		l *zap.Logger,
		sSetting SupabaseSettingParams,
	) (out sfx.AuthMiddlewareResult, err error) {
		c, err := supabase.NewClient(sSetting.URL, sSetting.Key, nil)
		if err != nil {
			return
		}
		out.AuthMiddleware = &SupabaseAuthor{
			client:        c,
			unAuthMethods: map[string]struct{}{},
		}
		return
	},
)

SupabaseCheckModule is the supabase Auth module for grpc middleware

View Source
var SupabaseSettingsModule = fx.Provide(
	func() (out SupabaseSettingsResult, err error) {
		err = out.LoadFromEnv()
		return
	},
)

SupabaseSettingsModule is the supabase settings module you can find them in https://app.supabase.io/project/setting/api

Functions

This section is empty.

Types

type FirebaseAuthor

type FirebaseAuthor struct {
	// contains filtered or unexported fields
}

FirebaseAuthor is auth for grpc middleware

func (*FirebaseAuthor) AddUnAuthMethod

func (d *FirebaseAuthor) AddUnAuthMethod(method string)

AddUnAuthMethod add unauth method

func (*FirebaseAuthor) Auth

Auth will auth every grpc request with firebase https://firebase.google.com/docs/auth/admin/verify-id-tokens NOTE: here we use firebase verifyIDToken to auth every grpc request,not to check the token has not been revoked or disabled. if you need to check the token has not been revoked please use VerifyIDTokenAndCheckRevoked to replace VerifyIDToken.

type FirebaseSettingParams

type FirebaseSettingParams struct {
	fx.In

	KeyFile string `name:"FirebaseKeyFile"`
}

FirebaseSettingParams module params for injecting FirebaseSettings

type FirebaseSettingsResult

type FirebaseSettingsResult struct {
	fx.Out

	KeyFile string `name:"FirebaseKeyFile" envconfig:"FIREBASE_KEY_FILE" default:"./configs/firebase/serviceAccountKey.json"`
}

FirebaseSettingsResult module result for exporting FirebaseSettings

func (*FirebaseSettingsResult) LoadFromEnv

func (g *FirebaseSettingsResult) LoadFromEnv() error

LoadFromEnv load from env

type SupabaseAuthor

type SupabaseAuthor struct {
	// contains filtered or unexported fields
}

SupabaseAuthor is auth for grpc middleware

func (*SupabaseAuthor) AddUnAuthMethod

func (d *SupabaseAuthor) AddUnAuthMethod(method string)

AddUnAuthMethod add unauth method

func (*SupabaseAuthor) Auth

Auth will auth every grpc request with supabase

type SupabaseSettingParams

type SupabaseSettingParams struct {
	fx.In

	URL string `name:"supabaseUrl"`
	Key string `name:"supabaseKey"`
}

SupabaseSettingParams module params for injecting SupabaseSettings

type SupabaseSettingsResult

type SupabaseSettingsResult struct {
	fx.Out

	URL string `name:"supabaseUrl" envconfig:"SUPABASE_URL" default:""`
	Key string `name:"supabaseKey" envconfig:"SUPABASE_KEY" default:""`
}

SupabaseSettingsResult module result for exporting SupabaseSettings

func (*SupabaseSettingsResult) LoadFromEnv

func (g *SupabaseSettingsResult) LoadFromEnv() error

LoadFromEnv load from env

Jump to

Keyboard shortcuts

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