authn

package
v0.0.0-...-96f7096 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RedirectURICookie = "redirecturi"
	OAuthStateCookie  = "oauthstate"
	SessionCookieName = "teams_backend_session_id"
	IDTokenKey        = "id_token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Google

type Google struct {
	oauth2.Config
	// contains filtered or unexported fields
}

func NewGoogle

func NewGoogle(clientID, clientSecret, redirectURL string) *Google

func (*Google) Verify

func (g *Google) Verify(ctx context.Context, rawIDToken string) (*oidc.IDToken, error)

type Handler

type Handler interface {
	Login(w http.ResponseWriter, r *http.Request)
	Callback(w http.ResponseWriter, r *http.Request)
	Logout(w http.ResponseWriter, r *http.Request)
	SetSessionCookie(w http.ResponseWriter, session *db.Session)
	DeleteCookie(w http.ResponseWriter, name string)
}

func New

func New(oauth2Config OAuth2, database db.Database, frontendURL url.URL, log logger.Logger) Handler

type MockHandler

type MockHandler struct {
	mock.Mock
}

MockHandler is an autogenerated mock type for the Handler type

func NewMockHandler

func NewMockHandler(t interface {
	mock.TestingT
	Cleanup(func())
},
) *MockHandler

NewMockHandler creates a new instance of MockHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHandler) Callback

func (_m *MockHandler) Callback(w http.ResponseWriter, r *http.Request)

Callback provides a mock function with given fields: w, r

func (*MockHandler) DeleteCookie

func (_m *MockHandler) DeleteCookie(w http.ResponseWriter, name string)

DeleteCookie provides a mock function with given fields: w, name

func (*MockHandler) EXPECT

func (_m *MockHandler) EXPECT() *MockHandler_Expecter

func (*MockHandler) Login

func (_m *MockHandler) Login(w http.ResponseWriter, r *http.Request)

Login provides a mock function with given fields: w, r

func (*MockHandler) Logout

func (_m *MockHandler) Logout(w http.ResponseWriter, r *http.Request)

Logout provides a mock function with given fields: w, r

func (*MockHandler) SetSessionCookie

func (_m *MockHandler) SetSessionCookie(w http.ResponseWriter, session *db.Session)

SetSessionCookie provides a mock function with given fields: w, session

type MockHandler_Callback_Call

type MockHandler_Callback_Call struct {
	*mock.Call
}

MockHandler_Callback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Callback'

func (*MockHandler_Callback_Call) Return

func (*MockHandler_Callback_Call) Run

func (*MockHandler_Callback_Call) RunAndReturn

type MockHandler_DeleteCookie_Call

type MockHandler_DeleteCookie_Call struct {
	*mock.Call
}

MockHandler_DeleteCookie_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteCookie'

func (*MockHandler_DeleteCookie_Call) Return

func (*MockHandler_DeleteCookie_Call) Run

func (*MockHandler_DeleteCookie_Call) RunAndReturn

type MockHandler_Expecter

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

func (*MockHandler_Expecter) Callback

func (_e *MockHandler_Expecter) Callback(w interface{}, r interface{}) *MockHandler_Callback_Call

Callback is a helper method to define mock.On call

  • w http.ResponseWriter
  • r *http.Request

func (*MockHandler_Expecter) DeleteCookie

func (_e *MockHandler_Expecter) DeleteCookie(w interface{}, name interface{}) *MockHandler_DeleteCookie_Call

DeleteCookie is a helper method to define mock.On call

  • w http.ResponseWriter
  • name string

func (*MockHandler_Expecter) Login

func (_e *MockHandler_Expecter) Login(w interface{}, r interface{}) *MockHandler_Login_Call

Login is a helper method to define mock.On call

  • w http.ResponseWriter
  • r *http.Request

func (*MockHandler_Expecter) Logout

func (_e *MockHandler_Expecter) Logout(w interface{}, r interface{}) *MockHandler_Logout_Call

Logout is a helper method to define mock.On call

  • w http.ResponseWriter
  • r *http.Request

func (*MockHandler_Expecter) SetSessionCookie

func (_e *MockHandler_Expecter) SetSessionCookie(w interface{}, session interface{}) *MockHandler_SetSessionCookie_Call

SetSessionCookie is a helper method to define mock.On call

  • w http.ResponseWriter
  • session *db.Session

type MockHandler_Login_Call

type MockHandler_Login_Call struct {
	*mock.Call
}

MockHandler_Login_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Login'

func (*MockHandler_Login_Call) Return

func (*MockHandler_Login_Call) Run

func (*MockHandler_Login_Call) RunAndReturn

type MockHandler_Logout_Call

type MockHandler_Logout_Call struct {
	*mock.Call
}

MockHandler_Logout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Logout'

func (*MockHandler_Logout_Call) Return

func (*MockHandler_Logout_Call) Run

func (*MockHandler_Logout_Call) RunAndReturn

type MockHandler_SetSessionCookie_Call

type MockHandler_SetSessionCookie_Call struct {
	*mock.Call
}

MockHandler_SetSessionCookie_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetSessionCookie'

func (*MockHandler_SetSessionCookie_Call) Return

func (*MockHandler_SetSessionCookie_Call) Run

func (*MockHandler_SetSessionCookie_Call) RunAndReturn

type OAuth2

type OAuth2 interface {
	Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
	AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
	Verify(ctx context.Context, rawIDToken string) (*oidc.IDToken, error)
}

Jump to

Keyboard shortcuts

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