feature: local auth! (#441)

* feature: local auth!

* cicd: contentLogin -> content-login

* bugfix: CSS codestyle
This commit is contained in:
James Read 2024-10-17 14:23:01 +01:00 committed by GitHub
parent 32b5fee108
commit 71ad5d2e3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 70 additions and 0 deletions

View File

@ -209,6 +209,15 @@ message KillActionResponse {
bool found = 4; bool found = 4;
} }
message LocalUserLoginRequest {
string username = 1;
string password = 2;
}
message LocalUserLoginResponse {
string authenticated_user = 1;
}
service OliveTinApiService { service OliveTinApiService {
rpc GetDashboardComponents(GetDashboardComponentsRequest) returns (GetDashboardComponentsResponse) { rpc GetDashboardComponents(GetDashboardComponentsRequest) returns (GetDashboardComponentsResponse) {
option (google.api.http) = { option (google.api.http) = {
@ -298,4 +307,11 @@ service OliveTinApiService {
get: "/api/readyz" get: "/api/readyz"
}; };
} }
rpc Authenticate(LocalUserLoginRequest) returns (LocalUserLoginResponse) {
option (google.api.http) = {
post: "/api/authenticate"
body: "*"
};
}
} }

View File

@ -115,6 +115,7 @@ type Config struct {
AuthJwtPubKeyPath string // will read pub key from file on disk AuthJwtPubKeyPath string // will read pub key from file on disk
AuthHttpHeaderUsername string AuthHttpHeaderUsername string
AuthHttpHeaderUserGroup string AuthHttpHeaderUserGroup string
AuthUsernamePassword AuthUsernamePasswordConfig
AuthLoginUrl string AuthLoginUrl string
AuthAllowGuest bool AuthAllowGuest bool
AuthOAuth2RedirectURL string AuthOAuth2RedirectURL string
@ -139,6 +140,17 @@ type Config struct {
usedConfigDir string usedConfigDir string
} }
type AuthUsernamePasswordConfig struct {
Enabled bool
Users []*LocalUser
}
type LocalUser struct {
Username string
Password string
Groups []string
}
type OAuth2Provider struct { type OAuth2Provider struct {
Name string Name string
Title string Title string

View File

@ -94,6 +94,19 @@ func (api *oliveTinAPI) StartAction(ctx ctx.Context, req *pb.StartActionRequest)
}, nil }, nil
} }
func (api *oliveTinAPI) Authenticate(ctx ctx.Context, req *pb.LocalUserLoginRequest) (*pb.LocalUserLoginResponse, error) {
/*
user := acl.Authenticate(cfg, req.Username, req.Password)
if user == nil {
return nil, status.Errorf(codes.Unauthenticated, "Invalid username or password.")
}
*/
return &pb.LocalUserLoginResponse{
}, nil
}
func (api *oliveTinAPI) StartActionAndWait(ctx ctx.Context, req *pb.StartActionAndWaitRequest) (*pb.StartActionAndWaitResponse, error) { func (api *oliveTinAPI) StartActionAndWait(ctx ctx.Context, req *pb.StartActionAndWaitRequest) (*pb.StartActionAndWaitResponse, error) {
args := make(map[string]string) args := make(map[string]string)

View File

@ -92,6 +92,35 @@
</fieldset> </fieldset>
</section> </section>
<section id = "content-login" title = "Login" hidden>
<div class = "flex-col">
<form class = "box-shadow padded-content">
<h2>OAuth Login</h2>
<div>
<button>GitHub</button>
<button>Google</button>
</div>
<hr />
<h2>Local Login</h2>
<div class = "arguments">
<label for = "username">
<span>Username:</span>
</label>
<input type = "text" name = "username" />
<span></span>
<label for = "password">
<span>Password:</span>
</label>
<input type = "password" name = "password" />
<span></span>
<button type = "submit">Login</button>
</div>
</form>
</div>
</section>
<noscript> <noscript>
<div class = "error">Sorry, JavaScript is required to use OliveTin.</div> <div class = "error">Sorry, JavaScript is required to use OliveTin.</div>
</noscript> </noscript>