Compare commits
No commits in common. "master" and "master" have entirely different histories.
|
|
@ -34,7 +34,6 @@ XMPP
|
||||||
* __xmpp_secret__ : Account password
|
* __xmpp_secret__ : Account password
|
||||||
* xmpp_debug : Enable debug log at true (default: false)
|
* xmpp_debug : Enable debug log at true (default: false)
|
||||||
* xmpp_verify_cert_validity : Enable certificate verification (default: true)
|
* xmpp_verify_cert_validity : Enable certificate verification (default: true)
|
||||||
* xmpp_default_lang : Message default languages
|
|
||||||
|
|
||||||
HTTP
|
HTTP
|
||||||
* http_port : HTTP port to bind (default: -1, desactive: -1)
|
* http_port : HTTP port to bind (default: -1, desactive: -1)
|
||||||
|
|
@ -49,9 +48,6 @@ __Bold config__ are mandatory.
|
||||||
|
|
||||||
If ``http_bind_address_ipv4`` is set to ``0.0.0.0``, it will bind all address on IPv4 __AND__ IPv6.
|
If ``http_bind_address_ipv4`` is set to ``0.0.0.0``, it will bind all address on IPv4 __AND__ IPv6.
|
||||||
|
|
||||||
The lang messages file must be placed into the same directory than the configuration file.
|
|
||||||
An example of this file can be found in [the repos](https://git.kingpenguin.tk/chteufleur/HTTPAuthentificationOverXMPP/src/master/messages.lang)
|
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
To ask authorization, just send an HTTP request to the path ``/auth`` with parameters:
|
To ask authorization, just send an HTTP request to the path ``/auth`` with parameters:
|
||||||
* __jid__ : JID of the user (user@host/resource or user@host)
|
* __jid__ : JID of the user (user@host/resource or user@host)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,2 @@
|
||||||
en=_DOMAIN_ (with method _METHOD_) need to validate your identity, do you agree?\nValidation code: _VALIDE_CODE_\nPlease check that this code is the same as on _DOMAIN_.\n\nIf your client doesn't support that functionality, please send back the validation code to confirm the request.
|
en=_DOMAIN_ (with method _METHOD_) need to validate your identity, do you agree ?\nValidation code : _VALIDE_CODE_\nPlease check that this code is the same as on _DOMAIN_.\n\nIf your client doesn't support that functionnality, please send back the validation code to confirm the request.
|
||||||
fr=_DOMAIN_ (avec la methode _METHOD_) a besoin de valider votre identitée, acceptez-vous ?\nCode de validation : _VALIDE_CODE_\nVeuillez vérifier que ce code est le même que sur _DOMAIN_.\n\nSi votre client ne support pas cette fonctionnalitée, veuilez renvoyer le code de validation pour confirmer la requête.
|
fr=_DOMAIN_ (avec la methode _METHOD_) a besoin de valider votre identitée, acceptez-vous ?\nVeuillez vérifier que ce code est le même que sur _DOMAIN_.\n\nSi votre client ne support pas cette fonctionnalitée, veuilez renvoyer le code de validation pour confirmer la requête.
|
||||||
ca=_DOMAIN_ (via _METHOD_) validarà la teva identitat, hi estàs d'acord?\nCodi de validació: _VALIDE_CODE_ \nComprova que aquest codi sigui el mateix que a _DOMAIN_.\n\nSi la teva aplicació no contempla aquesta funcionalitat, respon a aquest missatge amb el codi per a confirmar la petició.
|
|
||||||
es=_DOMAIN_ (via _METHOD_) validará tu identitad, estás de acuerdo?\nCódigo de validación: _VALIDE_CODE_ \nComprueba que el código sea el mismo que en _DOMAIN_.\n\nSi tu aplicación no contempla esta funcionalidad, responde a este mensaje con el código para confirmar la petición.
|
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@ func (confirmation *Confirmation) SendConfirmation() {
|
||||||
func (confirmation *Confirmation) askViaIQ() {
|
func (confirmation *Confirmation) askViaIQ() {
|
||||||
stanzaID++
|
stanzaID++
|
||||||
stanzaIDstr := strconv.Itoa(stanzaID)
|
stanzaIDstr := strconv.Itoa(stanzaID)
|
||||||
m := xmpp.IQ{Type: xmpp.IQTypeGet, To: confirmation.JID, From: jid.Full(), ID: stanzaIDstr}
|
m := xmpp.Iq{Type: xmpp.IQTypeGet, To: confirmation.JID, From: jid.Full(), Id: stanzaIDstr}
|
||||||
confirm := &xmpp.Confirm{ID: confirmation.Transaction, Method: confirmation.Method, URL: confirmation.Domain}
|
confirm := &xmpp.Confirm{Id: confirmation.Transaction, Method: confirmation.Method, URL: confirmation.Domain}
|
||||||
m.PayloadEncode(confirm)
|
m.PayloadEncode(confirm)
|
||||||
WaitIqMessages[stanzaIDstr] = confirmation
|
WaitIqMessages[stanzaIDstr] = confirmation
|
||||||
comp.Out <- m
|
comp.Out <- m
|
||||||
|
|
@ -65,7 +65,7 @@ func (confirmation *Confirmation) askViaMessage() {
|
||||||
m := xmpp.Message{From: jid.Full(), To: confirmation.JID, Type: xmpp.MessageTypeNormal}
|
m := xmpp.Message{From: jid.Full(), To: confirmation.JID, Type: xmpp.MessageTypeNormal}
|
||||||
m.Thread = xmpp.SessionID()
|
m.Thread = xmpp.SessionID()
|
||||||
confirmation.setBodies(&m)
|
confirmation.setBodies(&m)
|
||||||
m.Confirm = &xmpp.Confirm{ID: confirmation.Transaction, Method: confirmation.Method, URL: confirmation.Domain}
|
m.Confir = &xmpp.Confirm{Id: confirmation.Transaction, Method: confirmation.Method, URL: confirmation.Domain}
|
||||||
|
|
||||||
log.Printf("%sSend message %v", LogInfo, m)
|
log.Printf("%sSend message %v", LogInfo, m)
|
||||||
WaitMessageAnswers[confirmation.Transaction] = confirmation
|
WaitMessageAnswers[confirmation.Transaction] = confirmation
|
||||||
|
|
|
||||||
16
xmpp/xmpp.go
16
xmpp/xmpp.go
|
|
@ -93,9 +93,9 @@ func mainXMPP() {
|
||||||
case *xmpp.Presence:
|
case *xmpp.Presence:
|
||||||
|
|
||||||
case *xmpp.Message:
|
case *xmpp.Message:
|
||||||
confirm := v.Confirm
|
confirm := v.Confir
|
||||||
if confirm != nil {
|
if confirm != nil {
|
||||||
confirmation := WaitMessageAnswers[confirm.ID]
|
confirmation := WaitMessageAnswers[confirm.Id]
|
||||||
processConfirm(v, confirmation)
|
processConfirm(v, confirmation)
|
||||||
} else {
|
} else {
|
||||||
// If body is the confirmation id, it will be considerated as accepted.
|
// If body is the confirmation id, it will be considerated as accepted.
|
||||||
|
|
@ -109,7 +109,7 @@ func mainXMPP() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case *xmpp.IQ:
|
case *xmpp.Iq:
|
||||||
switch v.PayloadName().Space {
|
switch v.PayloadName().Space {
|
||||||
case xmpp.NSDiscoInfo:
|
case xmpp.NSDiscoInfo:
|
||||||
execDisco(v)
|
execDisco(v)
|
||||||
|
|
@ -131,12 +131,12 @@ func mainXMPP() {
|
||||||
case xmpp.NSHTTPAuth:
|
case xmpp.NSHTTPAuth:
|
||||||
confirm := &xmpp.Confirm{}
|
confirm := &xmpp.Confirm{}
|
||||||
v.PayloadDecode(confirm)
|
v.PayloadDecode(confirm)
|
||||||
confirmation := WaitIqMessages[v.ID]
|
confirmation := WaitIqMessages[v.Id]
|
||||||
processConfirm(v, confirmation)
|
processConfirm(v, confirmation)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Handle reply iq that doesn't contain HTTP-Auth namespace
|
// Handle reply iq that doesn't contain HTTP-Auth namespace
|
||||||
confirmation := WaitIqMessages[v.ID]
|
confirmation := WaitIqMessages[v.Id]
|
||||||
processConfirm(v, confirmation)
|
processConfirm(v, confirmation)
|
||||||
|
|
||||||
if confirmation == nil {
|
if confirmation == nil {
|
||||||
|
|
@ -154,7 +154,7 @@ func mainXMPP() {
|
||||||
|
|
||||||
func processConfirm(x interface{}, confirmation *Confirmation) {
|
func processConfirm(x interface{}, confirmation *Confirmation) {
|
||||||
mes, mesOK := x.(*xmpp.Message)
|
mes, mesOK := x.(*xmpp.Message)
|
||||||
iq, iqOK := x.(*xmpp.IQ)
|
iq, iqOK := x.(*xmpp.Iq)
|
||||||
|
|
||||||
if confirmation != nil {
|
if confirmation != nil {
|
||||||
if mesOK && mes.Error != nil {
|
if mesOK && mes.Error != nil {
|
||||||
|
|
@ -195,7 +195,7 @@ func must(v interface{}, err error) interface{} {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func execDisco(iq *xmpp.IQ) {
|
func execDisco(iq *xmpp.Iq) {
|
||||||
log.Printf("%sDisco Feature", LogInfo)
|
log.Printf("%sDisco Feature", LogInfo)
|
||||||
|
|
||||||
discoInfoReceived := &xmpp.DiscoItems{}
|
discoInfoReceived := &xmpp.DiscoItems{}
|
||||||
|
|
@ -226,7 +226,7 @@ func execDisco(iq *xmpp.IQ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func execDiscoCommand(iq *xmpp.IQ) {
|
func execDiscoCommand(iq *xmpp.Iq) {
|
||||||
log.Printf("%sAd-Hoc Command", LogInfo)
|
log.Printf("%sAd-Hoc Command", LogInfo)
|
||||||
reply := iq.Response(xmpp.IQTypeResult)
|
reply := iq.Response(xmpp.IQTypeResult)
|
||||||
discoItem := &xmpp.DiscoItems{Node: xmpp.NodeAdHocCommand}
|
discoItem := &xmpp.DiscoItems{Node: xmpp.NodeAdHocCommand}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue