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"
|
2022-11-20 08:49:24 -05:00
|
|
|
"dynatron.me/x/blasphem/pkg/flow"
|
2022-11-12 16:31:26 -05:00
|
|
|
"dynatron.me/x/blasphem/pkg/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
type User struct {
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
|
|
|
|
provider.AuthProvider `json:"-"`
|
|
|
|
}
|
|
|
|
|
2022-11-13 11:55:10 -05:00
|
|
|
func (hau *User) UserData() provider.ProviderUser {
|
|
|
|
return &UserData{
|
2022-12-18 21:26:34 -05:00
|
|
|
UserID: hau.UserID,
|
|
|
|
AuthProvider: hau.AuthProvider,
|
2022-11-12 16:31:26 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-18 21:26:34 -05:00
|
|
|
func (hau *UserData) Provider() provider.AuthProvider {
|
|
|
|
return hau.AuthProvider
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hau *User) Provider() provider.AuthProvider {
|
|
|
|
return hau.AuthProvider
|
|
|
|
}
|
|
|
|
|
2022-11-12 16:31:26 -05:00
|
|
|
type UserData struct {
|
|
|
|
UserID string `json:"user_id"`
|
2022-12-18 21:26:34 -05:00
|
|
|
|
|
|
|
provider.AuthProvider `json:"-"`
|
2022-11-12 16:31:26 -05:00
|
|
|
}
|
|
|
|
|
2022-11-13 11:55:10 -05:00
|
|
|
func (ud *UserData) UserData() provider.ProviderUser {
|
|
|
|
return ud
|
|
|
|
}
|
2022-11-12 16:31:26 -05:00
|
|
|
|
2022-11-13 11:55:10 -05:00
|
|
|
const TrustedNetworks = "trusted_networks"
|
2022-11-12 16:31:26 -05:00
|
|
|
|
|
|
|
type TrustedNetworksProvider struct {
|
|
|
|
provider.AuthProviderBase `json:"-"`
|
|
|
|
}
|
|
|
|
|
2022-12-18 21:26:34 -05:00
|
|
|
func (hap *TrustedNetworksProvider) EqualCreds(c1, c2 provider.ProviderUser) bool {
|
|
|
|
panic("not implemented")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-11-12 16:31:26 -05:00
|
|
|
func New(s storage.Store) (provider.AuthProvider, error) {
|
|
|
|
hap := &TrustedNetworksProvider{
|
|
|
|
AuthProviderBase: provider.AuthProviderBase{
|
|
|
|
Name: "Trusted Networks",
|
|
|
|
Type: TrustedNetworks,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return hap, nil
|
|
|
|
}
|
|
|
|
|
2022-11-13 19:06:53 -05:00
|
|
|
func (tnp *TrustedNetworksProvider) Lookup(pu provider.ProviderUser) provider.ProviderUser {
|
|
|
|
return pu
|
|
|
|
}
|
|
|
|
|
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{}
|
|
|
|
}
|
|
|
|
|
2022-11-20 12:51:26 -05:00
|
|
|
func (hap *TrustedNetworksProvider) FlowSchema() flow.Schema {
|
2022-12-27 15:09:20 -05:00
|
|
|
return nil
|
2022-11-12 16:31:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
provider.Register(TrustedNetworks, New)
|
|
|
|
}
|