Skip to content

Commit

Permalink
chore: rename provider package to auth package
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiebens committed Oct 9, 2022
1 parent daf577a commit dfb91d2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion internal/provider/oidc.go → internal/auth/oidc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package provider
package auth

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/providers.go → internal/auth/provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package provider
package auth

type AuthProvider interface {
type Provider interface {
GetLoginURL(redirectURI, state string) string
Exchange(redirectURI, code string) (*User, error)
}
Expand Down
12 changes: 6 additions & 6 deletions internal/handlers/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"github.com/jsiebens/ionscale/internal/addr"
"github.com/jsiebens/ionscale/internal/provider"
"github.com/jsiebens/ionscale/internal/auth"
"github.com/labstack/echo/v4/middleware"
"github.com/mr-tron/base58"
"net/http"
Expand All @@ -20,7 +20,7 @@ import (

func NewAuthenticationHandlers(
config *config.Config,
authProvider provider.AuthProvider,
authProvider auth.Provider,
systemIAMPolicy *domain.IAMPolicy,
repository domain.Repository) *AuthenticationHandlers {

Expand All @@ -34,7 +34,7 @@ func NewAuthenticationHandlers(

type AuthenticationHandlers struct {
repository domain.Repository
authProvider provider.AuthProvider
authProvider auth.Provider
config *config.Config
systemIAMPolicy *domain.IAMPolicy
}
Expand Down Expand Up @@ -233,11 +233,11 @@ func (h *AuthenticationHandlers) Callback(c echo.Context) error {
return c.Redirect(http.StatusFound, "/a/error")
}

func (h *AuthenticationHandlers) isSystemAdmin(ctx context.Context, u *provider.User) (bool, error) {
func (h *AuthenticationHandlers) isSystemAdmin(ctx context.Context, u *auth.User) (bool, error) {
return h.systemIAMPolicy.EvaluatePolicy(&domain.Identity{UserID: u.ID, Email: u.Name, Attr: u.Attr})
}

func (h *AuthenticationHandlers) listAvailableTailnets(ctx context.Context, u *provider.User) ([]domain.Tailnet, error) {
func (h *AuthenticationHandlers) listAvailableTailnets(ctx context.Context, u *auth.User) ([]domain.Tailnet, error) {
var result = []domain.Tailnet{}
tailnets, err := h.repository.ListTailnets(ctx)
if err != nil {
Expand Down Expand Up @@ -534,7 +534,7 @@ func (h *AuthenticationHandlers) endMachineRegistrationFlow(c echo.Context, regi
return c.Redirect(http.StatusFound, "/a/success")
}

func (h *AuthenticationHandlers) exchangeUser(code string) (*provider.User, error) {
func (h *AuthenticationHandlers) exchangeUser(code string) (*auth.User, error) {
redirectUrl := h.config.CreateUrl("/a/callback")

user, err := h.authProvider.Exchange(redirectUrl, code)
Expand Down
6 changes: 3 additions & 3 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"fmt"
"github.com/caddyserver/certmagic"
"github.com/hashicorp/go-hclog"
"github.com/jsiebens/ionscale/internal/auth"
"github.com/jsiebens/ionscale/internal/bind"
"github.com/jsiebens/ionscale/internal/config"
"github.com/jsiebens/ionscale/internal/database"
"github.com/jsiebens/ionscale/internal/dns"
"github.com/jsiebens/ionscale/internal/domain"
"github.com/jsiebens/ionscale/internal/handlers"
"github.com/jsiebens/ionscale/internal/provider"
"github.com/jsiebens/ionscale/internal/service"
"github.com/jsiebens/ionscale/internal/templates"
echo_prometheus "github.com/labstack/echo-contrib/prometheus"
Expand Down Expand Up @@ -210,12 +210,12 @@ func Start(c *config.Config) error {
return g.Wait()
}

func setupAuthProvider(config config.Auth) (provider.AuthProvider, *domain.IAMPolicy, error) {
func setupAuthProvider(config config.Auth) (auth.Provider, *domain.IAMPolicy, error) {
if len(config.Provider.Issuer) == 0 {
return nil, &domain.IAMPolicy{}, nil
}

authProvider, err := provider.NewOIDCProvider(&config.Provider)
authProvider, err := auth.NewOIDCProvider(&config.Provider)
if err != nil {
return nil, nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package service
import (
"context"
"github.com/bufbuild/connect-go"
"github.com/jsiebens/ionscale/internal/auth"
"github.com/jsiebens/ionscale/internal/broker"
"github.com/jsiebens/ionscale/internal/config"
"github.com/jsiebens/ionscale/internal/domain"
"github.com/jsiebens/ionscale/internal/provider"
"github.com/jsiebens/ionscale/internal/version"
api "github.com/jsiebens/ionscale/pkg/gen/ionscale/v1"
)

func NewService(config *config.Config, authProvider provider.AuthProvider, repository domain.Repository, pubsub broker.Pubsub) *Service {
func NewService(config *config.Config, authProvider auth.Provider, repository domain.Repository, pubsub broker.Pubsub) *Service {
return &Service{
config: config,
authProvider: authProvider,
Expand All @@ -22,7 +22,7 @@ func NewService(config *config.Config, authProvider provider.AuthProvider, repos

type Service struct {
config *config.Config
authProvider provider.AuthProvider
authProvider auth.Provider
repository domain.Repository
pubsub broker.Pubsub
}
Expand Down

0 comments on commit dfb91d2

Please sign in to comment.