87 lines
1.7 KiB
Go
87 lines
1.7 KiB
Go
package trustednets
|
|
|
|
// TODO: This doesn't work at all
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"dynatron.me/x/blasphem/pkg/auth/provider"
|
|
"dynatron.me/x/blasphem/pkg/flow"
|
|
"dynatron.me/x/blasphem/pkg/storage"
|
|
)
|
|
|
|
type User struct {
|
|
UserID string `json:"user_id"`
|
|
|
|
provider.AuthProvider `json:"-"`
|
|
}
|
|
|
|
func (hau *User) UserData() provider.ProviderUser {
|
|
return &UserData{
|
|
UserID: hau.UserID,
|
|
AuthProvider: hau.AuthProvider,
|
|
}
|
|
}
|
|
|
|
func (hau *UserData) Provider() provider.AuthProvider {
|
|
return hau.AuthProvider
|
|
}
|
|
|
|
func (hau *User) Provider() provider.AuthProvider {
|
|
return hau.AuthProvider
|
|
}
|
|
|
|
type UserData struct {
|
|
UserID string `json:"user_id"`
|
|
|
|
provider.AuthProvider `json:"-"`
|
|
}
|
|
|
|
func (ud *UserData) UserData() provider.ProviderUser {
|
|
return ud
|
|
}
|
|
|
|
const TrustedNetworks = "trusted_networks"
|
|
|
|
type TrustedNetworksProvider struct {
|
|
provider.AuthProviderBase `json:"-"`
|
|
}
|
|
|
|
func (hap *TrustedNetworksProvider) EqualCreds(c1, c2 provider.ProviderUser) bool {
|
|
panic("not implemented")
|
|
return false
|
|
}
|
|
|
|
func New(s storage.Store) (provider.AuthProvider, error) {
|
|
hap := &TrustedNetworksProvider{
|
|
AuthProviderBase: provider.AuthProviderBase{
|
|
Name: "Trusted Networks",
|
|
Type: TrustedNetworks,
|
|
},
|
|
}
|
|
|
|
return hap, nil
|
|
}
|
|
|
|
func (tnp *TrustedNetworksProvider) Lookup(pu provider.ProviderUser) provider.ProviderUser {
|
|
return pu
|
|
}
|
|
|
|
func (hap *TrustedNetworksProvider) ValidateCreds(r *http.Request, rm map[string]interface{}) (provider.ProviderUser, bool) {
|
|
/*
|
|
if req.RemoteAddr in allowed then do the thing
|
|
*/
|
|
return nil, false
|
|
}
|
|
|
|
func (hap *TrustedNetworksProvider) NewCredData() interface{} {
|
|
return &UserData{}
|
|
}
|
|
|
|
func (hap *TrustedNetworksProvider) FlowSchema() flow.Schema {
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
provider.Register(TrustedNetworks, New)
|
|
}
|