2022-11-12 16:31:26 -05:00
|
|
|
package trustednets
|
|
|
|
|
|
|
|
// TODO: This doesn't work at all
|
|
|
|
|
|
|
|
import (
|
2022-11-12 17:31:03 -05:00
|
|
|
"net/http"
|
|
|
|
|
2022-11-12 16:31:26 -05:00
|
|
|
"dynatron.me/x/blasphem/pkg/auth/provider"
|
|
|
|
"dynatron.me/x/blasphem/pkg/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
type User struct {
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
|
|
|
|
provider.AuthProvider `json:"-"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hau *User) UserData() interface{} {
|
|
|
|
return UserData{
|
|
|
|
UserID: hau.UserID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserData struct {
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
const TrustedNetworks = "trusted_networks"
|
|
|
|
|
|
|
|
func (h *User) ProviderUserData() interface{} { return h.UserData() }
|
|
|
|
|
|
|
|
type TrustedNetworksProvider struct {
|
|
|
|
provider.AuthProviderBase `json:"-"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func New(s storage.Store) (provider.AuthProvider, error) {
|
|
|
|
hap := &TrustedNetworksProvider{
|
|
|
|
AuthProviderBase: provider.AuthProviderBase{
|
|
|
|
Name: "Trusted Networks",
|
|
|
|
Type: TrustedNetworks,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return hap, nil
|
|
|
|
}
|
|
|
|
|
2022-11-12 17:31:03 -05:00
|
|
|
func (hap *TrustedNetworksProvider) ValidateCreds(r *http.Request, rm map[string]interface{}) (provider.ProviderUser, bool) {
|
|
|
|
/*
|
2022-11-12 17:42:51 -05:00
|
|
|
if req.RemoteAddr in allowed then do the thing
|
2022-11-12 17:31:03 -05:00
|
|
|
*/
|
2022-11-12 16:31:26 -05:00
|
|
|
return nil, false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hap *TrustedNetworksProvider) NewCredData() interface{} {
|
|
|
|
return &UserData{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hap *TrustedNetworksProvider) FlowSchema() []provider.FlowSchemaItem {
|
|
|
|
return []provider.FlowSchemaItem{
|
|
|
|
{
|
|
|
|
Type: "string",
|
|
|
|
Name: "username",
|
|
|
|
Required: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "string",
|
|
|
|
Name: "password",
|
|
|
|
Required: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
provider.Register(TrustedNetworks, New)
|
|
|
|
}
|