Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
KenWilliamson committed Jan 26, 2020
1 parent de17337 commit 37dc287
Show file tree
Hide file tree
Showing 15 changed files with 510 additions and 498 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ go 1.12

require (
github.com/Ulbora/GoProxy v1.0.1
github.com/Ulbora/auth_interface v1.0.0
github.com/Ulbora/dbinterface v1.0.5
github.com/Ulbora/dbinterface_mysql v1.0.7
github.com/Ulbora/default_auth v1.0.0
github.com/Ulbora/go-sessions v1.0.2
github.com/gbrlsnchs/jwt/v3 v3.0.0-rc.1
github.com/gorilla/mux v1.7.3
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/Ulbora/GoProxy v1.0.1 h1:7gFPaJdXDV3tFDSWYxpQx7SQmNKcZPrv4SMwxa+vFhA=
github.com/Ulbora/GoProxy v1.0.1/go.mod h1:8qICy+U1tSywRYoy9RdP+Zm6G2nN2K1YcvMupVlkIYI=
github.com/Ulbora/auth_interface v1.0.0 h1:VOlwvngE1XqmtIpuga0bC/pz6g5cCNeMnKQEeEXWVzw=
github.com/Ulbora/auth_interface v1.0.0/go.mod h1:i8dptQU29zmoscU4NHtddNpBltSi9oLDQXylQgnqxFs=
github.com/Ulbora/dbinterface v1.0.3 h1:To53y2igWp5p/SkFX4zubWQOQJ6DF4KbPRWFVHeRD2I=
github.com/Ulbora/dbinterface v1.0.3/go.mod h1:msBriehF2JgLgSpNWq2Yc3MKy3/Rn9aChefibmW1xWM=
github.com/Ulbora/dbinterface v1.0.5 h1:hzAsS92kIKIApFb6av1vGGz4+lRNOyfzhh5HXxoUiIg=
Expand All @@ -18,6 +20,8 @@ github.com/Ulbora/dbinterface_mysql v1.0.6 h1:NBWVtCmz5VwqXLHPlYSg3Um3hTu9uSVFLI
github.com/Ulbora/dbinterface_mysql v1.0.6/go.mod h1:8XA1eoibXMbJNIfL5mvl7b77FZPSRewInYCNFRC65AQ=
github.com/Ulbora/dbinterface_mysql v1.0.7 h1:rFOaRaKaARFLEd8hYxvFIbbN49FFI2j/m7iy10sGOas=
github.com/Ulbora/dbinterface_mysql v1.0.7/go.mod h1:8XA1eoibXMbJNIfL5mvl7b77FZPSRewInYCNFRC65AQ=
github.com/Ulbora/default_auth v1.0.0 h1:CaCbl50AOGdIScK9envXMNxgpP4lpeDTXLDTPaoRlSU=
github.com/Ulbora/default_auth v1.0.0/go.mod h1:YiXsU5bzKm9Pa5m+Y2aUqy65Ta0NCRcsVslWzjTmsyk=
github.com/Ulbora/go-sessions v1.0.0 h1:Y8WiW5fnsG7iVAadNhWqGVsbq8Rag/TzJ1fJWm58LQ4=
github.com/Ulbora/go-sessions v1.0.0/go.mod h1:5CXZMqyt5XJDumnxoKqftZH/i3voi9k1UN47fuwxRLs=
github.com/Ulbora/go-sessions v1.0.1 h1:QslZUmI54dg39qoQSzKcQP0fxb4LEhEnR12FZBJ5qsA=
Expand Down
430 changes: 215 additions & 215 deletions handlers/coverage.out

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions handlers/utilites.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
rc "github.com/Ulbora/GoAuth2/rolecontrol"
px "github.com/Ulbora/GoProxy"
db "github.com/Ulbora/dbinterface"
dau "github.com/Ulbora/default_auth"
// mdb "github.com/Ulbora/dbinterface_mysql"
)

Expand All @@ -38,7 +39,7 @@ import (
*/

//UseWebHandler UseWebHandler
func UseWebHandler(dbi db.Database, compressJtw bool) *OauthWebHandler {
func UseWebHandler(dbi db.Database, compressJtw bool, authURL string) *OauthWebHandler {
var oauthManagerw m.OauthManager
var oauthMySqldbw msdb.MySQLOauthDB
oauthMySqldbw.DB = dbi
Expand All @@ -48,21 +49,33 @@ func UseWebHandler(dbi db.Database, compressJtw bool) *OauthWebHandler {
var userServiceProxy px.GoProxy
oauthManagerw.Proxy = userServiceProxy.GetNewProxy()

var proxy px.GoProxy
var da dau.DefaultAuth
da.AuthServerURL = authURL
da.Proxy = proxy.GetNewProxy()
oauthManagerw.AuthService = da.GetNew()

var wh OauthWebHandler
wh.Manager = &oauthManagerw
wh.TokenCompressed = compressJtw
return &wh
}

//UseRestHandler UseRestHandler
func UseRestHandler(dbi db.Database, assets string, compressJtw bool) *OauthRestHandler {
func UseRestHandler(dbi db.Database, assets string, compressJtw bool, authURL string) *OauthRestHandler {
var oauthManager m.OauthManager
var oauthMySqldb msdb.MySQLOauthDB
oauthMySqldb.DB = dbi
var oauthDb odb.Oauth2DB
oauthDb = &oauthMySqldb
oauthManager.Db = oauthDb

var proxy px.GoProxy
var da dau.DefaultAuth
da.AuthServerURL = authURL
da.Proxy = proxy.GetNewProxy()
oauthManager.AuthService = da.GetNew()

var rh OauthRestHandler
rh.Manager = &oauthManager

Expand Down
4 changes: 2 additions & 2 deletions handlers/utilites_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestUseHanders_UseWebHandler(t *testing.T) {
var dbi db.Database
h := UseWebHandler(dbi, false)
h := UseWebHandler(dbi, false, "url")
if h == nil {
t.Fail()
}
Expand All @@ -18,7 +18,7 @@ func TestUseHanders_UseWebHandler(t *testing.T) {
func TestUseHanders_UseRestHandler(t *testing.T) {
var dbi db.Database
var assets = "WwogICB7CiAgICAgICJ1cmwiOiIvdWxib3JhL3JzL2NsaWVudEFsbG93ZWRVcmkvYWRkIiwKICAgICAgImFzc2V0cyI6WwogICAgICAgICB7CiAgICAgICAgICAgICJjb250cm9sbGVkQXNzZXQiOiJ1bGJvcmEiLAogICAgICAgICAgICAiYWxsb3dlZFJvbGUiOiJzdXBlckFkbWluIgogICAgICAgICB9CiAgICAgIF0KICAgfSwKICAgewogICAgICAidXJsIjoiL3VsYm9yYS9ycy9jbGllbnRBbGxvd2VkVXJpL3VwZGF0ZSIsCiAgICAgICJhc3NldHMiOlsKICAgICAgICAgewogICAgICAgICAgICAiY29udHJvbGxlZEFzc2V0IjoidWxib3JhIiwKICAgICAgICAgICAgImFsbG93ZWRSb2xlIjoic3VwZXJBZG1pbiIKICAgICAgICAgfQogICAgICBdCiAgIH0sCiAgIHsKICAgICAgInVybCI6Ii91bGJvcmEvcnMvY2xpZW50Um9sZS9hZGQiLAogICAgICAiYXNzZXRzIjpbCiAgICAgICAgIHsKICAgICAgICAgICAgImNvbnRyb2xsZWRBc3NldCI6InN1cGVyQWRtaW4iLAogICAgICAgICAgICAiYWxsb3dlZFJvbGUiOiJzdXBlckFkbWluIgogICAgICAgICB9CiAgICAgIF0KICAgfQpd"
h := UseRestHandler(dbi, assets, false)
h := UseRestHandler(dbi, assets, false, "url")
if h == nil {
t.Fail()
}
Expand Down
5 changes: 2 additions & 3 deletions handlers/webLoginHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package handlers

import (
"fmt"
au "github.com/Ulbora/auth_interface"
"net/http"
"strconv"

m "github.com/Ulbora/GoAuth2/managers"
)

/*
Expand Down Expand Up @@ -90,7 +89,7 @@ func (h *OauthWebHandler) LoginUser(w http.ResponseWriter, r *http.Request) {
password := r.FormValue("password")
fmt.Println("username", username)
fmt.Println("password", password)
var lg m.Login
var lg au.Login
lg.ClientID = lari.ClientID
lg.Username = username
lg.Password = password
Expand Down
3 changes: 2 additions & 1 deletion handlers/webTokenHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strconv"

m "github.com/Ulbora/GoAuth2/managers"
au "github.com/Ulbora/auth_interface"
)

/*
Expand Down Expand Up @@ -76,7 +77,7 @@ func (h *OauthWebHandler) Token(w http.ResponseWriter, r *http.Request) {
fmt.Println("username: ", username)
password := r.FormValue("password")
fmt.Println("password: ", password)
var lg m.Login
var lg au.Login
lg.ClientID = clientID
lg.Username = username
lg.Password = password
Expand Down
Binary file modified main
Binary file not shown.
Loading

0 comments on commit 37dc287

Please sign in to comment.