login

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is the local server used to perform a user login in IMS.

The usage pattern for the login server (minus error handling, for simplicity) is the following.

// Start the service
srv := login.NewServer(cfg)

// Listen on a separate goroutine
go srv.Serve(listener)

// Wait for a response.
select {
case res := <-srv.Response():
    // Process the login response.
case err := <-srv.Error():
    // An error occurred.
case <- time.After(5 * time.Minute):
    // Bail out after some time.
}

// Close the server.
srv.Shutdown()

func NewServer

func NewServer(cfg *ServerConfig) (*Server, error)

NewServer creates a new Server for the provided ServerConfig.

func (*Server) Error

func (s *Server) Error() <-chan error

Error returns a channel that can be listened to for error conditions.

func (*Server) Response

func (s *Server) Response() <-chan *ims.TokenResponse

Response returns a channel that can be listened to for a successful login.

func (*Server) Serve

func (s *Server) Serve(lst net.Listener) error

Serve make the server listen to the provided listener.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown closes the server and the channels returned from Error() and Response(). When closing the server, this method has the same semantics of http.Server.Shutdown.

type ServerConfig

type ServerConfig struct {
	// The IMS client.
	Client *ims.Client
	// The client ID.
	ClientID string
	// The client secret.
	ClientSecret string
	// List of scopes to request.
	Scope []string
	// The URL to be redirected after authentication
	RedirectURI string
	// A custom handler for sending an error response to the client. If not
	// provided, a default response is sent.
	OnError http.Handler
	// A custom handler for sending a success response to the client. If not
	// provided, a default response is sent.
	OnSuccess http.Handler
	// Use PKCE in the authorization code flow.
	UsePKCE bool
}

ServerConfig is the configuration for the login server.

Jump to

Keyboard shortcuts

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