Compare commits

..

2 Commits

Author SHA1 Message Date
Chteufleur 4cb6a14eb9 Add configuration documentation 2016-06-21 21:04:37 +02:00
Chteufleur 02202b94d5 Make some config with default value 2016-06-21 21:03:32 +02:00
3 changed files with 32 additions and 7 deletions

View File

@ -19,12 +19,23 @@ 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 component and HTTP server informations.
XMPP
* xmpp_server_address : Component server address connection (default: 127.0.0.1)
* xmpp_server_port : Component server port connection (default: 5347)
* xmpp_hostname : Component hostname
* xmpp_secret : Component password
* xmpp_debug : Enable debug log at true (default: false)
HTTP
* http_port : HTTP port to bind (default: 9090)
* http_timeoute_sec : Define a timeout if user did not give an answer to the request (default: 60)
### Utilization ### Utilization
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)
* domain: Domain you want to access * domain : Domain you want to access
* method: Method you access the domain * method : Method you access the domain
* transaction_id: Transaction identifier * transaction_id : Transaction identifier
Example: Example:
``` ```

View File

@ -5,4 +5,6 @@ xmpp_hostname=xmppsteam.kingpenguin.tk
xmpp_secret=xmpp4steam_password xmpp_secret=xmpp4steam_password
xmpp_debug=true xmpp_debug=true
# HTTP informations
http_port=9090 http_port=9090
http_timeoute_sec=60

18
main.go
View File

@ -17,6 +17,9 @@ import (
const ( const (
Version = "v0.1.0" Version = "v0.1.0"
configurationFilePath = "httpAuth.cfg" configurationFilePath = "httpAuth.cfg"
default_xmpp_server_address = "127.0.0.1"
default_xmpp_server_port = "5347"
) )
var ( var (
@ -32,17 +35,26 @@ func init() {
// HTTP config // HTTP config
httpTimeout, err := strconv.Atoi(mapConfig["http_timeoute_sec"]) httpTimeout, err := strconv.Atoi(mapConfig["http_timeoute_sec"])
if err == nil { if err == nil {
log.Println("Define HTTP timeout to %d second", httpTimeout) log.Println("Define HTTP timeout to "+strconv.Itoa(httpTimeout)+" second")
http.TimeoutSec = httpTimeout http.TimeoutSec = httpTimeout
} }
httpPort, err := strconv.Atoi(mapConfig["http_port"]) httpPort, err := strconv.Atoi(mapConfig["http_port"])
if err == nil { if err == nil {
log.Println("Define HTTP port to %d", httpPort) log.Println("Define HTTP port to "+strconv.Itoa(httpPort))
http.HttpPortBind = httpPort http.HttpPortBind = httpPort
} }
// XMPP config // XMPP config
xmpp.Addr = mapConfig["xmpp_server_address"] + ":" + mapConfig["xmpp_server_port"] xmpp_server_address := mapConfig["xmpp_server_address"]
if xmpp_server_address == "" {
xmpp_server_address = default_xmpp_server_address
}
xmpp_server_port := mapConfig["xmpp_server_port"]
if xmpp_server_port == "" {
xmpp_server_port = default_xmpp_server_port
}
xmpp.Addr = xmpp_server_address + ":" + xmpp_server_port
xmpp.JidStr = mapConfig["xmpp_hostname"] xmpp.JidStr = mapConfig["xmpp_hostname"]
xmpp.Secret = mapConfig["xmpp_secret"] xmpp.Secret = mapConfig["xmpp_secret"]
xmpp.Debug = mapConfig["xmpp_debug"] == "true" xmpp.Debug = mapConfig["xmpp_debug"] == "true"