mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-31 23:41:09 +02:00
Simplified, and de-duplicated many of the configuration settings. Removed configuration settings that could be deduced from other settings. Added some basic documentation. Removed the (duplicate?) user email domain validation check in proxy. Removed the ClientID middleware check. Added a shared key option to be used as a PSK instead of using the IDPs ClientID and ClientSecret. Removed the CookieSecure setting as we only support secure. Added a letsencrypt script to generate a wildcard certificate. Removed the argument in proxy's constructor that allowed arbitrary fucntions to be passed in as validators. Updated proxy's authenticator client to match the server implementation of just using a PSK. Moved debug-mode logging into the log package. Removed unused approval prompt setting. Fixed a bug where identity provider urls were hardcoded. Removed a bunch of unit tests. There have been so many changes many of these tests don't make sense and will need to be re-thought.
82 lines
2.2 KiB
Go
82 lines
2.2 KiB
Go
package providers // import "github.com/pomerium/pomerium/internal/providers"
|
|
|
|
import (
|
|
"net/url"
|
|
"time"
|
|
|
|
"github.com/pomerium/pomerium/internal/sessions"
|
|
)
|
|
|
|
// TestProvider is a test implementation of the Provider interface.
|
|
type TestProvider struct {
|
|
*ProviderData
|
|
|
|
ValidToken bool
|
|
ValidGroup bool
|
|
SignInURL string
|
|
Refresh bool
|
|
RefreshFunc func(string) (string, time.Duration, error)
|
|
RefreshError error
|
|
Session *sessions.SessionState
|
|
RedeemError error
|
|
RevokeError error
|
|
Groups []string
|
|
GroupsError error
|
|
GroupsCall int
|
|
}
|
|
|
|
// NewTestProvider creates a new mock test provider.
|
|
func NewTestProvider(providerURL *url.URL) *TestProvider {
|
|
host := &url.URL{
|
|
Scheme: "http",
|
|
Host: providerURL.Host,
|
|
Path: "/authorize",
|
|
}
|
|
return &TestProvider{
|
|
ProviderData: &ProviderData{
|
|
ProviderName: "Test Provider",
|
|
ProviderURL: host.String(),
|
|
},
|
|
}
|
|
}
|
|
|
|
// ValidateSessionState returns the mock provider's ValidToken field value.
|
|
func (tp *TestProvider) ValidateSessionState(*sessions.SessionState) bool {
|
|
return tp.ValidToken
|
|
}
|
|
|
|
// GetSignInURL returns the mock provider's SignInURL field value.
|
|
func (tp *TestProvider) GetSignInURL(finalRedirect string) string {
|
|
return tp.SignInURL
|
|
}
|
|
|
|
// RefreshSessionIfNeeded returns the mock provider's Refresh value, or an error.
|
|
func (tp *TestProvider) RefreshSessionIfNeeded(*sessions.SessionState) (bool, error) {
|
|
return tp.Refresh, tp.RefreshError
|
|
}
|
|
|
|
// RefreshAccessToken returns the mock provider's refresh access token information
|
|
func (tp *TestProvider) RefreshAccessToken(s string) (string, time.Duration, error) {
|
|
return tp.RefreshFunc(s)
|
|
}
|
|
|
|
// Revoke returns nil
|
|
func (tp *TestProvider) Revoke(*sessions.SessionState) error {
|
|
return tp.RevokeError
|
|
}
|
|
|
|
// ValidateGroupMembership returns the mock provider's GroupsError if not nil, or the Groups field value.
|
|
func (tp *TestProvider) ValidateGroupMembership(string, []string) ([]string, error) {
|
|
return tp.Groups, tp.GroupsError
|
|
}
|
|
|
|
// Redeem returns the mock provider's Session and RedeemError field value.
|
|
func (tp *TestProvider) Redeem(code string) (*sessions.SessionState, error) {
|
|
return tp.Session, tp.RedeemError
|
|
|
|
}
|
|
|
|
// Stop fulfills the Provider interface
|
|
func (tp *TestProvider) Stop() {
|
|
return
|
|
}
|