Skip to content

Commit

Permalink
chore: rename some internals
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiebens committed Feb 6, 2022
1 parent 70921ba commit 887cd67
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions internal/auth/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type SessionRegistry interface {
CheckSessionToken(request *api.SessionTokenRequest) (*api.SessionTokenResponse, error)
}

func NewRemoteSessionRegistrar(config config.Auth) (SessionRegistry, error) {
func NewRemoteSessionRegistry(config config.Auth) (SessionRegistry, error) {
url, err := util.NormalizeHttpUrl(config.RemoteServer)
if err != nil {
return nil, err
Expand All @@ -31,7 +31,7 @@ func NewRemoteSessionRegistrar(config config.Auth) (SessionRegistry, error) {
if err != nil {
return nil, err
}
return &remoteSessionRegistrar{
return &remoteSessionRegistry{
client: resty.New(),
authServerBaseUrl: url,
remotePublicKey: *publicKey,
Expand All @@ -40,7 +40,7 @@ func NewRemoteSessionRegistrar(config config.Auth) (SessionRegistry, error) {
}, nil
}

type remoteSessionRegistrar struct {
type remoteSessionRegistry struct {
client *resty.Client
authServerBaseUrl string
remotePublicKey key.PublicKey
Expand All @@ -49,11 +49,11 @@ type remoteSessionRegistrar struct {
localPublicKey string
}

func (r *remoteSessionRegistrar) GetPublicKey() key.PublicKey {
func (r *remoteSessionRegistry) GetPublicKey() key.PublicKey {
return r.remotePublicKey
}

func (r *remoteSessionRegistrar) RegisterSession(req *api.RegisterSessionRequest) (*api.SessionTokenResponse, error) {
func (r *remoteSessionRegistry) RegisterSession(req *api.RegisterSessionRequest) (*api.SessionTokenResponse, error) {
token, err := r.localPrivateKey.SealBase58(r.remotePublicKey, &api.Token{ExpirationTime: time.Now().UTC().Add(5 * time.Minute)})
if err != nil {
return nil, err
Expand Down Expand Up @@ -82,7 +82,7 @@ func (r *remoteSessionRegistrar) RegisterSession(req *api.RegisterSessionRequest
return &result, nil
}

func (r *remoteSessionRegistrar) CheckSessionToken(req *api.SessionTokenRequest) (*api.SessionTokenResponse, error) {
func (r *remoteSessionRegistry) CheckSessionToken(req *api.SessionTokenRequest) (*api.SessionTokenResponse, error) {
token, err := r.localPrivateKey.SealBase58(r.remotePublicKey, &api.Token{ExpirationTime: time.Now().UTC().Add(5 * time.Minute)})
if err != nil {
return nil, err
Expand Down
36 changes: 18 additions & 18 deletions internal/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ func StartServer(config *config.Config) error {
sessionRegistry = authServer
} else {
logrus.Info("configuring remote auth server, skipping oidc routes")
remoteSessionRegistrar, err := auth.NewRemoteSessionRegistrar(config.Auth)
remoteSessionRegistry, err := auth.NewRemoteSessionRegistry(config.Auth)
if err != nil {
return err
}
sessionRegistry = remoteSessionRegistrar
sessionRegistry = remoteSessionRegistry
}

logrus.Info("registering proxy routes")
Expand All @@ -71,7 +71,7 @@ func StartServer(config *config.Config) error {
return server.Start(config, e)
}

func NewServer(config config.Proxy, cache cache.Cache, registrar auth.SessionRegistry) (*Server, error) {
func NewServer(config config.Proxy, cache cache.Cache, registry auth.SessionRegistry) (*Server, error) {
targetFilters, err := parseTargetFilters(config.Policies)
if err != nil {
return nil, err
Expand All @@ -82,23 +82,23 @@ func NewServer(config config.Proxy, cache cache.Cache, registrar auth.SessionReg
return nil, err
}

server := &Server{
sessionRegistrar: registrar,
sessions: cache,
policy: config.Policies,
targetFilters: targetFilters,
checksum: checksum,
s := &Server{
sessionRegistry: registry,
sessions: cache,
policy: config.Policies,
targetFilters: targetFilters,
checksum: checksum,
}

return server, nil
return s, nil
}

type Server struct {
sessionRegistrar auth.SessionRegistry
sessions cache.Cache
policy map[string]config.Policy
targetFilters map[string][]TargetFilter
checksum string
sessionRegistry auth.SessionRegistry
sessions cache.Cache
policy map[string]config.Policy
targetFilters map[string][]TargetFilter
checksum string
}

type session struct {
Expand Down Expand Up @@ -154,7 +154,7 @@ func (s *Server) checkSessionToken(c echo.Context) error {
return err
}

response, err := s.sessionRegistrar.CheckSessionToken(&req)
response, err := s.sessionRegistry.CheckSessionToken(&req)
if err != nil {
return err
}
Expand Down Expand Up @@ -183,7 +183,7 @@ func (s *Server) authorizeClient(req *http.Request) (string, bool, remotedialer.
}

privateKey := se.PrivateKey
publicKey := s.sessionRegistrar.GetPublicKey()
publicKey := s.sessionRegistry.GetPublicKey()

var u = &api.SessionToken{}
if err := privateKey.OpenBase58(publicKey, auth, u); err != nil {
Expand Down Expand Up @@ -251,7 +251,7 @@ func (s *Server) registerSession(id, key, authToken, target string) (*api.Sessio
Checksum: s.checksum,
}

return s.sessionRegistrar.RegisterSession(&request)
return s.sessionRegistry.RegisterSession(&request)
}

func (s *Server) validateRolesAndTarget(roles []string, target string) bool {
Expand Down

0 comments on commit 887cd67

Please sign in to comment.