2021-10-08 12:39:31 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
|
|
|
//
|
2021-02-09 11:53:33 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-02-04 10:36:02 +00:00
|
|
|
package router
|
|
|
|
|
|
|
|
import "github.com/gorilla/mux"
|
|
|
|
|
|
|
|
// constant names for the named routes
|
|
|
|
const (
|
2021-03-25 17:38:21 +00:00
|
|
|
AuthLogin = "auth:login"
|
|
|
|
AuthLogout = "auth:logout"
|
2021-03-26 10:50:16 +00:00
|
|
|
|
2021-03-26 15:30:57 +00:00
|
|
|
AuthFallbackLogin = "auth:fallback:login"
|
|
|
|
AuthFallbackFinalize = "auth:fallback:finalize"
|
|
|
|
|
|
|
|
AuthWithSSBLogin = "auth:withssb:login"
|
2021-03-26 10:50:16 +00:00
|
|
|
AuthWithSSBServerEvents = "auth:withssb:sse"
|
|
|
|
AuthWithSSBFinalize = "auth:withssb:finalize"
|
2021-02-04 10:36:02 +00:00
|
|
|
)
|
|
|
|
|
2021-03-24 17:31:37 +00:00
|
|
|
// Auth constructs a mux.Router containing the routes for sign-in and -out
|
2021-02-04 10:36:02 +00:00
|
|
|
func Auth(m *mux.Router) *mux.Router {
|
|
|
|
if m == nil {
|
|
|
|
m = mux.NewRouter()
|
|
|
|
}
|
|
|
|
|
2021-03-25 17:38:21 +00:00
|
|
|
m.Path("/login").Methods("GET").Name(AuthLogin)
|
|
|
|
m.Path("/logout").Methods("GET").Name(AuthLogout)
|
|
|
|
|
2021-03-26 15:30:57 +00:00
|
|
|
m.Path("/fallback/login").Methods("GET").Name(AuthFallbackLogin)
|
|
|
|
m.Path("/fallback/finalize").Methods("POST").Name(AuthFallbackFinalize)
|
2021-03-17 09:46:05 +00:00
|
|
|
|
2021-03-26 15:30:57 +00:00
|
|
|
m.Path("/withssb/login").Methods("GET").Name(AuthWithSSBLogin)
|
2021-03-26 10:50:16 +00:00
|
|
|
m.Path("/withssb/events").Methods("GET").Name(AuthWithSSBServerEvents)
|
|
|
|
m.Path("/withssb/finalize").Methods("GET").Name(AuthWithSSBFinalize)
|
|
|
|
|
2021-02-04 10:36:02 +00:00
|
|
|
return m
|
|
|
|
}
|