Example #1
0
func (T POGSvc) Add(t POGc) {
	u, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil")
	if error == "" {
		s := SecInfo{u.Domain, u.SecurityToken}
		Add(t.GUUserID, t.RecordID, t.Name, t.AccessLevel, t.OtherData, s)
	} else {
		T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("Security Token Not Incorrect"))
	}
}
Example #2
0
func (T TenantSvc) CreateTenant(t Tenant) {
	//fmt.Println(T.Context.Request().Header["SecurityToken"])
	user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil")
	if error == "" {
		th := TenantHandler{}
		b, _ := json.Marshal(th.CreateTenant(t, user, false))
		T.ResponseBuilder().SetResponseCode(200).WriteAndOveride(b)

	}
}
Example #3
0
func (T TenantSvc) AcceptRequest(securityLevel, RequestToken string, accept bool) bool {
	//fmt.Println(T.Context.Request().Header.Get("Securitytoken"))
	user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil")
	if error == "" {
		th := TenantHandler{}
		return th.AcceptRequest(user, securityLevel, RequestToken, accept)
	} else {
		T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken  not Autherized"))
		return false
	}
}
Example #4
0
func (T TenantSvc) InviteUser(users []InviteUsers) {
	//fmt.Println(T.Context.Request().Header.Get("Securitytoken"))
	user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil")
	if error == "" {
		th := TenantHandler{}
		th.AddUserToTenant(user, users)
	} else {
		T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken  not Autherized"))
		return
	}
}
Example #5
0
func (T POGSvc) GetUsers(RecordID string) (c []string) {
	u, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil")
	if error == "" {
		s := SecInfo{u.Domain, u.SecurityToken}
		c = GetUsers(RecordID, s)
		return
	} else {
		T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("Security Token Not Incorrect"))
		return
	}
}
Example #6
0
func (T TenantSvc) GetTenant(TenantID string) Tenant {
	//fmt.Println(T.Context.Request().Header.Get("Securitytoken"))
	_, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil")
	//outCrt = TenantAutherize{}

	if error == "" {
		th := TenantHandler{}
		return th.GetTenant(TenantID)
	} else {
		T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken  not Autherized"))
		return Tenant{}
	}
}
Example #7
0
func (T TenantSvc) Subciribe(TenantID string) bool {
	//users :=InviteUsers[]{"Sss",sss,sss}

	//fmt.Println(T.Context.Request().Header.Get("Securitytoken"))
	user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil")
	if error == "" {
		th := TenantHandler{}
		return th.RequestToTenant(user, TenantID)
	} else {
		T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken  not Autherized"))
		return
	}
}
Example #8
0
func (T TenantSvc) GetTenants(securityToken string) []TenantMinimum {
	//fmt.Println()
	tns := []TenantMinimum{}
	user, error := session.GetSession(securityToken, "Nil")
	//outCrt = TenantAutherize{}

	if error == "" {
		th := TenantHandler{}
		return th.GetTenantsForUser(user.UserID)
	} else {
		T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken  not Autherized"))
	}
	return tns
}
Example #9
0
func (T TenantSvc) Autherized(TenantID string) (outCrt TenantAutherized) {
	//fmt.Println(T.Context.Request().Header["SecurityToken"])
	user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil")
	//outCrt = TenantAutherize{}

	if error == "" {
		th := TenantHandler{}
		b, d := th.Autherized(TenantID, user)

		if b {
			outCrt = d
			return d
		} else {
			T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("Tenant ID " + TenantID + " not Atherized"))
			return
		}
	} else {
		T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken  not Autherized"))
		return
	}
}
Example #10
0
func (h *AuthHandler) GetSession(key, Domain string) (AuthCertificate, string) {
	//bytes, err := client.Go(key, "s.duosoftware.auth", "sessions").GetOne().ByUniqueKey(key).Ok()
	//term.Write("GetSession For SecurityToken "+key, term.Debug)
	a, err := session.GetSession(key, Domain)
	var c AuthCertificate
	if err == "" {
		c.ClientIP = a.ClientIP
		c.DataCaps = a.DataCaps
		c.Domain = a.Domain
		c.Email = a.Email
		c.Name = a.Name
		c.SecurityToken = a.SecurityToken
		c.UserID = a.UserID
		c.Username = a.Username
		return c, ""
	} else {
		term.Write("GetSession Error "+err, term.Error)
	}
	term.Write("GetSession No Session for SecurityToken "+key, term.Debug)

	return c, "Error Session Not Found"
}