Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Remote triggering a pipeline #158

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
baf2a2d
WIP for trigger.
Jan 27, 2019
b54f46b
Started working on remote triggering a pipeline.
Skarlso Jan 27, 2019
39cb5bc
Need to find a better way to inject a handler.. but maybe this is okay.
Skarlso Jan 28, 2019
8cb6b85
Merge branch 'master' into issues_151_remote_pipeline_trigger
Skarlso Jan 29, 2019
fcd7fc3
Put the user generation into the right place.
Skarlso Jan 29, 2019
3a7529a
Auto user authentication.
Skarlso Feb 1, 2019
8723c30
Merge branch 'master' into issues_151_remote_pipeline_trigger
Skarlso Feb 1, 2019
468f95f
Updated auth.
Skarlso Feb 1, 2019
b15e00c
Update server.go
Skarlso Feb 1, 2019
cad9cfd
Remote triggering works now.
Feb 1, 2019
ef2da3e
Do not use a pointer.
Feb 1, 2019
869da62
This now works with parameters.
Feb 1, 2019
79789b5
Okay this works now.
Feb 1, 2019
f0549b9
Added endpoints to reset the token... no front-end work yet.
Skarlso Feb 1, 2019
047a506
Updated echo.
Skarlso Feb 1, 2019
5e9c775
Displaying the tokens for users and pipelines.
Skarlso Feb 2, 2019
8052619
Fixed failing tests.
Skarlso Feb 2, 2019
c4eca5e
Working user token re-generation.
Skarlso Feb 2, 2019
aacba8f
Extra warding..
Skarlso Feb 2, 2019
b0c9331
Only allow token reset for auto user.
Skarlso Feb 2, 2019
6d5816e
Only allow token reset for auto user.
Skarlso Feb 2, 2019
473e78c
No need to autogenerate the password. No real login will be performed…
Feb 2, 2019
d3196fd
Disallow deleting the auto user.
Skarlso Feb 2, 2019
cc9712c
First test.
Skarlso Feb 2, 2019
6615b40
Merge branch 'master' into issues_151_remote_pipeline_trigger
Feb 3, 2019
78e52b5
First pipeline test.
Feb 3, 2019
c99b3f6
Resetting mock.
Skarlso Feb 3, 2019
6895ee0
Moar coverage.
Skarlso Feb 3, 2019
ca744f5
Added test for pipeline token reset.
Skarlso Feb 3, 2019
ffbc6bb
Moar coverage.
Skarlso Feb 3, 2019
341bda6
Addressed comments.
Skarlso Feb 4, 2019
33b095a
Moved trigger token generation to the right place.
Skarlso Feb 4, 2019
1beb4da
Using a random namespace.
Skarlso Feb 4, 2019
354b0ab
Extracted the secret uuid generation into a separate package.
Feb 5, 2019
cc38b64
Added test coverage.
Feb 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion handlers/user.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handlers

import (
"crypto/rand"
"crypto/rsa"
"net/http"
"time"
Expand Down Expand Up @@ -158,8 +159,12 @@ func UserResetTriggerToken(c echo.Context) error {
if user == nil {
return c.String(http.StatusBadRequest, "Error retrieving user")
}

nsUUID := uuid.NewV4()
triggerToken := uuid.NewV5(nsUUID, "autoTriggerToken")
token := make([]byte, 32)
rand.Read(token)
namespace := string(token)
triggerToken := uuid.NewV5(nsUUID, namespace)
user.TriggerToken = triggerToken.String()
err = ss.UserPut(user, true)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion store/store.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package store

import (
"crypto/rand"
"encoding/binary"
"fmt"
"path/filepath"
Expand Down Expand Up @@ -167,7 +168,10 @@ func (s *BoltStore) setupDatabase() error {

if u == nil {
nsUUID := uuid.NewV4()
triggerToken := uuid.NewV5(nsUUID, "autoTriggerToken")
token := make([]byte, 32)
rand.Read(token)
namespace := string(token)
triggerToken := uuid.NewV5(nsUUID, namespace)
auto := gaia.User{
DisplayName: "Auto User",
JwtExpiry: 0,
Expand Down
7 changes: 6 additions & 1 deletion workers/pipeline/create_pipeline.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pipeline

import (
"crypto/rand"
"errors"
"fmt"
"strings"
Expand Down Expand Up @@ -124,7 +125,11 @@ func CreatePipeline(p *gaia.CreatePipeline) {
}

nsUUID := uuid.NewV4()
p.Pipeline.TriggerToken = uuid.NewV5(nsUUID, "pipelineTriggerToken").String()
Skarlso marked this conversation as resolved.
Show resolved Hide resolved
token := make([]byte, 32)
rand.Read(token)
namespace := string(token)
p.Pipeline.TriggerToken = uuid.NewV5(nsUUID, namespace).String()

// Save the generated pipeline data
err = bP.SavePipeline(&p.Pipeline)
if err != nil {
Expand Down