1
0
Fork 0

cleaned up old references i forgot

Dieser Commit ist enthalten in:
Sebastian Tobie 2021-01-10 01:35:50 +01:00
Ursprung c22cb74864
Commit 06a237dd53
2 geänderte Dateien mit 12 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -9,14 +9,14 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/phuslu/log" "github.com/phuslu/log"
"go.sebtobie.de/httpserver" "go.sebtobie.de/httpserver/auth"
"gopkg.in/dgrijalva/jwt-go.v3" "gopkg.in/dgrijalva/jwt-go.v3"
) )
var defaccount = &account{ var defaccount = &account{
data: map[string]interface{}{ data: map[string]interface{}{
httpserver.AccountID: "", auth.AccountID: "",
httpserver.AccountAnon: true, auth.AccountAnon: true,
}, },
} }
@ -28,7 +28,7 @@ func maptoarray(m map[string]interface{}) (output []interface{}) {
} }
// Account returns the Account representation of the user // Account returns the Account representation of the user
func (s *SAML) Account(c *gin.Context) httpserver.Account { func (s *SAML) Account(c *gin.Context) auth.Account {
acc := &(*defaccount) acc := &(*defaccount)
acc.s = s acc.s = s
cookie, err := c.Cookie(s.Cookiename) cookie, err := c.Cookie(s.Cookiename)
@ -66,14 +66,14 @@ type account struct {
} }
func (a *account) Anonymous() bool { func (a *account) Anonymous() bool {
return a.data[httpserver.AccountAnon].(bool) return a.data[auth.AccountAnon].(bool)
} }
func (a *account) Redirect(c *gin.Context) { func (a *account) Redirect(c *gin.Context) {
id := uuid.New().String() id := uuid.New().String()
tokenstring, err := jwttoken(jwt.MapClaims{ tokenstring, err := jwttoken(jwt.MapClaims{
httpserver.AccountID: id, auth.AccountID: id,
httpserver.AccountAnon: true, auth.AccountAnon: true,
}, a.s.jwtprivatekey) }, a.s.jwtprivatekey)
if err != nil { if err != nil {
log.Error().Err(err).Msg("Failed to generate the token") log.Error().Err(err).Msg("Failed to generate the token")

Datei anzeigen

@ -14,16 +14,10 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/pelletier/go-toml" "github.com/pelletier/go-toml"
"github.com/phuslu/log" "github.com/phuslu/log"
"go.sebtobie.de/httpserver" "go.sebtobie.de/httpserver/auth"
"gopkg.in/dgrijalva/jwt-go.v3" "gopkg.in/dgrijalva/jwt-go.v3"
) )
const (
HJWT = "jwt"
HSPPrivate = "sppriv"
HSPPublic = "sppub"
)
var ( var (
defaultsaml = &SAML{ defaultsaml = &SAML{
Selfsigned: false, Selfsigned: false,
@ -141,7 +135,7 @@ func (s *SAML) metadataHF(c *gin.Context) {
} }
func (s *SAML) acsHF(c *gin.Context) { func (s *SAML) acsHF(c *gin.Context) {
account := c.MustGet("account").(httpserver.Account) account := c.MustGet("account").(auth.Account)
err := c.Request.ParseForm() err := c.Request.ParseForm()
if err != nil { if err != nil {
c.AbortWithError(http.StatusNotAcceptable, err) c.AbortWithError(http.StatusNotAcceptable, err)
@ -158,9 +152,9 @@ func (s *SAML) acsHF(c *gin.Context) {
} }
data := attributeStatementstomap(assert.AttributeStatements) data := attributeStatementstomap(assert.AttributeStatements)
token, err := jwttoken(jwt.MapClaims{ token, err := jwttoken(jwt.MapClaims{
httpserver.AccountAnon: false, auth.AccountAnon: false,
httpserver.AccountID: account.Get(httpserver.AccountID).(string), auth.AccountID: account.Get(auth.AccountID).(string),
httpserver.AccountUser: data["uid"][0], auth.AccountUser: data["uid"][0],
}, s.jwtprivatekey) }, s.jwtprivatekey)
if err != nil { if err != nil {
c.AbortWithStatus(http.StatusInternalServerError) c.AbortWithStatus(http.StatusInternalServerError)