Compare commits

..

No commits in common. "4cb6a14eb9a93c1c0da0c93b1f3992024600557e" and "dec43cdddb5383b54df1786d76d3523babdca1f1" have entirely different histories.

3 changed files with 7 additions and 32 deletions

View File

@ -19,23 +19,12 @@ 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,6 +5,4 @@ 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,9 +17,6 @@ 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 (
@ -35,26 +32,17 @@ 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 "+strconv.Itoa(httpTimeout)+" second") log.Println("Define HTTP timeout to %d second", httpTimeout)
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 "+strconv.Itoa(httpPort)) log.Println("Define HTTP port to %d", httpPort)
http.HttpPortBind = httpPort http.HttpPortBind = httpPort
} }
// XMPP config // XMPP config
xmpp_server_address := mapConfig["xmpp_server_address"] xmpp.Addr = mapConfig["xmpp_server_address"] + ":" + mapConfig["xmpp_server_port"]
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"