Compare commits
6 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
ea4f78e23b | |
|
|
8384410023 | |
|
|
5fa7fe5235 | |
|
|
a330e7df29 | |
|
|
a00eb69071 | |
|
|
6337ad74af |
|
|
@ -34,6 +34,7 @@ XMPP
|
|||
* __xmpp_secret__ : Account password
|
||||
* xmpp_debug : Enable debug log at true (default: false)
|
||||
* xmpp_verify_cert_validity : Enable certificate verification (default: true)
|
||||
* xmpp_default_lang : Message default languages
|
||||
|
||||
HTTP
|
||||
* http_port : HTTP port to bind (default: -1, desactive: -1)
|
||||
|
|
@ -48,6 +49,9 @@ __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.
|
||||
|
||||
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
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
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 ?\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.
|
||||
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.
|
||||
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.
|
||||
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() {
|
||||
stanzaID++
|
||||
stanzaIDstr := strconv.Itoa(stanzaID)
|
||||
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}
|
||||
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}
|
||||
m.PayloadEncode(confirm)
|
||||
WaitIqMessages[stanzaIDstr] = confirmation
|
||||
comp.Out <- m
|
||||
|
|
@ -65,7 +65,7 @@ func (confirmation *Confirmation) askViaMessage() {
|
|||
m := xmpp.Message{From: jid.Full(), To: confirmation.JID, Type: xmpp.MessageTypeNormal}
|
||||
m.Thread = xmpp.SessionID()
|
||||
confirmation.setBodies(&m)
|
||||
m.Confir = &xmpp.Confirm{Id: confirmation.Transaction, Method: confirmation.Method, URL: confirmation.Domain}
|
||||
m.Confirm = &xmpp.Confirm{ID: confirmation.Transaction, Method: confirmation.Method, URL: confirmation.Domain}
|
||||
|
||||
log.Printf("%sSend message %v", LogInfo, m)
|
||||
WaitMessageAnswers[confirmation.Transaction] = confirmation
|
||||
|
|
|
|||
16
xmpp/xmpp.go
16
xmpp/xmpp.go
|
|
@ -93,9 +93,9 @@ func mainXMPP() {
|
|||
case *xmpp.Presence:
|
||||
|
||||
case *xmpp.Message:
|
||||
confirm := v.Confir
|
||||
confirm := v.Confirm
|
||||
if confirm != nil {
|
||||
confirmation := WaitMessageAnswers[confirm.Id]
|
||||
confirmation := WaitMessageAnswers[confirm.ID]
|
||||
processConfirm(v, confirmation)
|
||||
} else {
|
||||
// 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 {
|
||||
case xmpp.NSDiscoInfo:
|
||||
execDisco(v)
|
||||
|
|
@ -131,12 +131,12 @@ func mainXMPP() {
|
|||
case xmpp.NSHTTPAuth:
|
||||
confirm := &xmpp.Confirm{}
|
||||
v.PayloadDecode(confirm)
|
||||
confirmation := WaitIqMessages[v.Id]
|
||||
confirmation := WaitIqMessages[v.ID]
|
||||
processConfirm(v, confirmation)
|
||||
|
||||
default:
|
||||
// Handle reply iq that doesn't contain HTTP-Auth namespace
|
||||
confirmation := WaitIqMessages[v.Id]
|
||||
confirmation := WaitIqMessages[v.ID]
|
||||
processConfirm(v, confirmation)
|
||||
|
||||
if confirmation == nil {
|
||||
|
|
@ -154,7 +154,7 @@ func mainXMPP() {
|
|||
|
||||
func processConfirm(x interface{}, confirmation *Confirmation) {
|
||||
mes, mesOK := x.(*xmpp.Message)
|
||||
iq, iqOK := x.(*xmpp.Iq)
|
||||
iq, iqOK := x.(*xmpp.IQ)
|
||||
|
||||
if confirmation != nil {
|
||||
if mesOK && mes.Error != nil {
|
||||
|
|
@ -195,7 +195,7 @@ func must(v interface{}, err error) interface{} {
|
|||
return v
|
||||
}
|
||||
|
||||
func execDisco(iq *xmpp.Iq) {
|
||||
func execDisco(iq *xmpp.IQ) {
|
||||
log.Printf("%sDisco Feature", LogInfo)
|
||||
|
||||
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)
|
||||
reply := iq.Response(xmpp.IQTypeResult)
|
||||
discoItem := &xmpp.DiscoItems{Node: xmpp.NodeAdHocCommand}
|
||||
|
|
|
|||
Loading…
Reference in New Issue