Version 0.4
- Change README to add connection as client - Change config xmpp_hostname to xmpp_jid - Make it possible to configure client connection (server and port)
This commit is contained in:
parent
c88ec7a32d
commit
78c8aecb8e
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
Provide an HTTP anthentification over XMPP. Implementation of [XEP-0070](https://xmpp.org/extensions/xep-0070.html).
|
Provide an HTTP anthentification over XMPP. Implementation of [XEP-0070](https://xmpp.org/extensions/xep-0070.html).
|
||||||
|
|
||||||
|
Can be run as a XMPP client or XMPP component.
|
||||||
|
|
||||||
|
|
||||||
## Compilation
|
## Compilation
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
@ -16,14 +18,14 @@ go get git.kingpenguin.tk/chteufleur/HTTPAuthentificationOverXMPP.git
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configure
|
### Configure
|
||||||
Configure the gateway by editing the ``httpAuth.cfg`` file in order to give all XMPP component and HTTP server informations.
|
Configure the gateway by editing the ``httpAuth.cfg`` file in order to give all XMPP and HTTP server informations.
|
||||||
An example of the config file can be found in [the repos](https://git.kingpenguin.tk/chteufleur/HTTPAuthentificationOverXMPP/src/master/httpAuth.cfg).
|
An example of the config file can be found in [the repos](https://git.kingpenguin.tk/chteufleur/HTTPAuthentificationOverXMPP/src/master/httpAuth.cfg).
|
||||||
|
|
||||||
XMPP
|
XMPP
|
||||||
* xmpp_server_address : Component server address connection (default: 127.0.0.1)
|
* xmpp_server_address : Component server address connection (default: 127.0.0.1)
|
||||||
* xmpp_server_port : Component server port connection (default: 5347)
|
* xmpp_server_port : Component server port connection (default: 5347)
|
||||||
* xmpp_hostname : Component hostname
|
* __xmpp_jid__ : Account JID
|
||||||
* xmpp_secret : Component password
|
* __xmpp_secret__ : Account password
|
||||||
* xmpp_debug : Enable debug log at true (default: false)
|
* xmpp_debug : Enable debug log at true (default: false)
|
||||||
|
|
||||||
HTTP
|
HTTP
|
||||||
|
|
@ -33,6 +35,7 @@ HTTP
|
||||||
* https_key_path : Path to the key file (default: ./key.pem)
|
* https_key_path : Path to the key file (default: ./key.pem)
|
||||||
* http_timeoute_sec : Define a timeout if user did not give an answer to the request (default: 60)
|
* http_timeoute_sec : Define a timeout if user did not give an answer to the request (default: 60)
|
||||||
|
|
||||||
|
__Bold config__ are mandatory.
|
||||||
|
|
||||||
### 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:
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,10 @@
|
||||||
# XMPP informations (component)
|
# XMPP informations (component)
|
||||||
xmpp_server_address=192.168.1.2
|
xmpp_server_address=192.168.1.2
|
||||||
xmpp_server_port=5347
|
xmpp_server_port=5347
|
||||||
xmpp_hostname=xmppsteam.kingpenguin.tk
|
xmpp_jid=xmppsteam.kingpenguin.tk
|
||||||
xmpp_secret=xmpp4steam_password
|
xmpp_secret=xmpp4steam_password
|
||||||
xmpp_debug=true
|
xmpp_debug=true
|
||||||
|
|
||||||
# XMPP informations (client)
|
|
||||||
#xmpp_hostname=toto@jabber.fr
|
|
||||||
#xmpp_secret=totoPwd
|
|
||||||
#xmpp_debug=true
|
|
||||||
|
|
||||||
# HTTP informations
|
# HTTP informations
|
||||||
http_port=9090
|
http_port=9090
|
||||||
https_port=9093
|
https_port=9093
|
||||||
|
|
|
||||||
13
main.go
13
main.go
|
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "v0.3.1"
|
Version = "v0.4"
|
||||||
configurationFilePath = "httpAuth.cfg"
|
configurationFilePath = "httpAuth.cfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -60,20 +60,11 @@ func init() {
|
||||||
xmpp.Port = xmpp_server_port
|
xmpp.Port = xmpp_server_port
|
||||||
}
|
}
|
||||||
|
|
||||||
xmpp.JidStr = mapConfig["xmpp_hostname"]
|
xmpp.JidStr = mapConfig["xmpp_jid"]
|
||||||
xmpp.Secret = mapConfig["xmpp_secret"]
|
xmpp.Secret = mapConfig["xmpp_secret"]
|
||||||
xmpp.Debug = mapConfig["xmpp_debug"] == "true"
|
xmpp.Debug = mapConfig["xmpp_debug"] == "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
func getChanString(c chan interface{}) string {
|
|
||||||
ret := ""
|
|
||||||
i := <-c
|
|
||||||
if v, ok := i.(string); ok {
|
|
||||||
ret = v
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
go http.Run()
|
go http.Run()
|
||||||
|
|
|
||||||
24
xmpp/xmpp.go
24
xmpp/xmpp.go
|
|
@ -11,11 +11,14 @@ const (
|
||||||
LogInfo = "\t[XMPP INFO]\t"
|
LogInfo = "\t[XMPP INFO]\t"
|
||||||
LogError = "\t[XMPP ERROR]\t"
|
LogError = "\t[XMPP ERROR]\t"
|
||||||
LogDebug = "\t[XMPP DEBUG]\t"
|
LogDebug = "\t[XMPP DEBUG]\t"
|
||||||
|
|
||||||
|
DEFAULT_SERVER_ADDRESS = "127.0.0.1"
|
||||||
|
DEFAULT_SERVER_PORT = "5347"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Addr = "127.0.0.1"
|
Addr = ""
|
||||||
Port = "5347"
|
Port = ""
|
||||||
JidStr = ""
|
JidStr = ""
|
||||||
Secret = ""
|
Secret = ""
|
||||||
|
|
||||||
|
|
@ -46,11 +49,24 @@ func Run() {
|
||||||
|
|
||||||
if isComponent {
|
if isComponent {
|
||||||
// component
|
// component
|
||||||
|
if Addr == "" {
|
||||||
|
Addr = DEFAULT_SERVER_ADDRESS
|
||||||
|
}
|
||||||
|
if Port == "" {
|
||||||
|
Port = DEFAULT_SERVER_PORT
|
||||||
|
}
|
||||||
addr = Addr + ":" + Port
|
addr = Addr + ":" + Port
|
||||||
} else {
|
} else {
|
||||||
// client
|
// client
|
||||||
addrs := must(xmpp.HomeServerAddrs(jid)).([]string)
|
if Addr == "" {
|
||||||
addr = addrs[0]
|
addrs := must(xmpp.HomeServerAddrs(jid)).([]string)
|
||||||
|
addr = addrs[0]
|
||||||
|
} else {
|
||||||
|
if Port == "" {
|
||||||
|
Port = DEFAULT_SERVER_PORT
|
||||||
|
}
|
||||||
|
addr = Addr + ":" + Port
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%sConnecting to %s", LogInfo, addr)
|
log.Printf("%sConnecting to %s", LogInfo, addr)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue