Documentation
¶
Overview ¶
Package login provides a local HTTP server that implements the OAuth 2.0 authorization code flow with Adobe IMS. It handles browser redirection, callback processing, and token exchange.
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) Response ¶
func (s *Server) Response() <-chan *ims.TokenResponse
Response returns a channel that can be listened to for a successful login.
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
// Resource is the RFC 8707 resource indicator(s) for audience-restricted
// tokens. Sent on the authorize request to bind the resource to the
// authorization code. Optional.
Resource []string
}
ServerConfig is the configuration for the login server.
Click to show internal directories.
Click to hide internal directories.