https://github.com/ulbora/default_auth
Used to add default authentication module plugin to GoAuth2
https://github.com/ulbora/default_auth
Last synced: about 1 month ago
JSON representation
Used to add default authentication module plugin to GoAuth2
- Host: GitHub
- URL: https://github.com/ulbora/default_auth
- Owner: Ulbora
- License: mit
- Created: 2020-01-24T01:11:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-01T17:34:49.000Z (about 5 years ago)
- Last Synced: 2025-01-26T13:22:06.432Z (3 months ago)
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Default authentication module used on GoAuth2
==============[](https://goreportcard.com/report/github.com/Ulbora/default_auth)
Can interface with any GoAuth2 proxy for any type of authentication service. GoAuth2Users meets all of the requirements below for a GoAuth2 Proxy.
### Any GoAuth2 Proxy service must meet the following requirement:
* Must implement the login method from github.com/Ulbora/auth_interface
```
type AuthInterface interface {
UserLogin(login *Login) bool
}
```
Example
```
import(
au "github.com/Ulbora/auth_interface"
px "github.com/Ulbora/GoProxy"
)type SomeAuth struct{
Proxy px.Proxy
AuthServerURL string
}func (m *SomeAuth) UserLogin(login *au.Login) bool {
// todo
}
```* The GoAuth2 Proxy must implement the code inside the "login" service to interface with the target authentication service.
### Validate User
```
Method: POSTURL: http://proxyURL/rs/user/login
```Request headers Example:
```
Content-Type = application/json
```
Request Body Example:
```
{
"username":"admin",
"password":"admin",
"clientId":10
}
```
Response:
```
{
"valid": true,
"code": "10"
}
```# Usage
```
import (
px "github.com/Ulbora/GoProxy"
au "github.com/Ulbora/auth_interface"
"testing"
)var authURL = "http://localhost:3001/rs/user/login"
var proxy px.GoProxy
var login au.Login
login.Username = "admin"
login.Password = "admin"
login.ClientID = 10var da DefaultAuth
da.AuthServerURL = authURL
da.Proxy = proxy.GetNewProxy()
ai := da.GetNew()
val := ai.UserLogin(&login)```