Skip to content

Commit

Permalink
wip: chain authentication functions
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Jul 24, 2024
1 parent b17726d commit 616de93
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions openfga/oas.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type OasAuthenticateOpt func(*OasAuthenticateOpts)
// OasDefaultAuthenticateOpts ...
func OasDefaultAuthenticateOpts() OasAuthenticateOpts {
return OasAuthenticateOpts{
Builder: &OasFGAAuthzBuilder{},
Builder: NewOasFGAAuthzBuilder(),
}
}

Expand Down Expand Up @@ -152,6 +152,19 @@ func OasAuthenticate(opts ...OasAuthenticateOpt) openapi3filter.AuthenticationFu
}
}

// Authenticate ...
func Authenticate(fn ...openapi3filter.AuthenticationFunc) openapi3filter.AuthenticationFunc {
return func(ctx context.Context, input *openapi3filter.AuthenticationInput) error {
for _, f := range fn {
if err := f(ctx, input); err != nil {
return err
}
}

return nil
}
}

// PathParam ...
func PathParams(params map[string]string, name string, v ...string) string {
s := ""
Expand Down Expand Up @@ -225,22 +238,3 @@ func DefaultAuthorizerOpts() AuthorizerOpts {
DefaultAuthorizer: DefaultAuthorizer,
}
}

// // Authenticate ...
// func Authenticate(opts ...AuthorizerOpt) openapi3filter.AuthenticationFunc {
// opts := DefaultAuthorizerOpts()

// return func(ctx context.Context, input *openapi3filter.AuthenticationInput) error {
// auth, ok := opts.Authorizers[input.SecuritySchemeName]
// if !ok {
// return opts.DefaultAuthorizer(ctx, input)
// }

// err := auth(ctx, input)
// if err != nil {
// return err
// }

// return auth(ctx, input)
// }
// }

0 comments on commit 616de93

Please sign in to comment.