Allow no authentication

Only when debugging is enabled. Allows skipping of authentication for usage with CAS and so forth.
This commit is contained in:
Spotlight 2021-07-24 18:27:32 -05:00
parent 8291cff180
commit dad74c7f82
No known key found for this signature in database
GPG Key ID: 874AA355B3209BDC
4 changed files with 13 additions and 0 deletions

View File

@ -16,4 +16,8 @@
<!-- Set to true to enable response debugging.
Can be extremely verbose. -->
<Debug>true</Debug>
<!-- Set to true to ignore authentication checks.
This is useful when testing CAS directly.
It is only functional when debug is enabled. -->
<NoAuth>false</NoAuth>
</Config>

View File

@ -37,6 +37,7 @@ var baseUrl string
var pool *pgxpool.Pool
var ctx = context.Background()
var isDebug = false
var ignoreAuth = false
// checkError makes error handling not as ugly and inefficient.
func checkError(err error) {
@ -58,6 +59,9 @@ func main() {
fmt.Println("[i] Initializing core...")
isDebug = readConfig.Debug
if isDebug {
ignoreAuth = readConfig.NoAuth
}
// Start SQL.
dbString := fmt.Sprintf("postgres://%s:%s@%s/%s", readConfig.SQLUser, readConfig.SQLPass, readConfig.SQLAddress, readConfig.SQLDB)

View File

@ -150,6 +150,10 @@ const (
// checkAuthentication validates various factors from a given request requiring authentication.
func checkAuthentication(e *Envelope) (bool, error) {
if ignoreAuth {
return true, nil
}
// Get necessary authentication identifiers.
deviceToken, err := getKey(e.doc, "DeviceToken")
if err != nil {

View File

@ -40,6 +40,7 @@ type Config struct {
SQLDB string `xml:"SQLDB"`
Debug bool `xml:"Debug"`
NoAuth bool `xml:"NoAuth"`
}
// Envelope represents the root element of any response, soapenv:Envelope.