🐛 Provide a way to bypass nexus and serving content to prevent nexus reverse proxy issue
This commit is contained in:
parent
2f99ac7b6e
commit
c41f8b77ce
@ -10,9 +10,17 @@
|
|||||||
<user-name>postgres</user-name>
|
<user-name>postgres</user-name>
|
||||||
<schema-mapping>
|
<schema-mapping>
|
||||||
<introspection-scope>
|
<introspection-scope>
|
||||||
<node kind="database" qname="@">
|
<node negative="1">
|
||||||
|
<node kind="database" qname="sn_paperclip">
|
||||||
|
<node kind="schema">
|
||||||
|
<name qname="@" />
|
||||||
|
<name qname="public" />
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node kind="database" qname="sn_passport">
|
||||||
<node kind="schema" qname="@" />
|
<node kind="schema" qname="@" />
|
||||||
</node>
|
</node>
|
||||||
|
</node>
|
||||||
</introspection-scope>
|
</introspection-scope>
|
||||||
</schema-mapping>
|
</schema-mapping>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4,9 +4,16 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":bug: Bug fixes">
|
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":bug: Fix hash bug">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/models/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/attachments.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/models/destination.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/destination.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/attachments_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/attachments_api.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/services/uploader.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/uploader.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/settings.toml" beforeDir="false" afterPath="$PROJECT_DIR$/settings.toml" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -44,7 +51,7 @@
|
|||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"DefaultGoTemplateProperty": "Go File",
|
"DefaultGoTemplateProperty": "Go File",
|
||||||
"Go Build.Backend.executor": "Run",
|
"Go Build.Backend.executor": "Debug",
|
||||||
"Go 构建.Backend.executor": "Run",
|
"Go 构建.Backend.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
||||||
@ -118,7 +125,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value=":bug: Fix doesn't get has lifecycle settings buckets correctly" />
|
|
||||||
<MESSAGE value=":zap: Fix the RandString method cause the lag" />
|
<MESSAGE value=":zap: Fix the RandString method cause the lag" />
|
||||||
<MESSAGE value=":bug: Fix mark clean required issue" />
|
<MESSAGE value=":bug: Fix mark clean required issue" />
|
||||||
<MESSAGE value=":sparkles: Support use rid to get file" />
|
<MESSAGE value=":sparkles: Support use rid to get file" />
|
||||||
@ -143,9 +149,46 @@
|
|||||||
<MESSAGE value=":recycle: Migrated to nexus" />
|
<MESSAGE value=":recycle: Migrated to nexus" />
|
||||||
<MESSAGE value=":wastebasket: Remove account" />
|
<MESSAGE value=":wastebasket: Remove account" />
|
||||||
<MESSAGE value=":bug: Bug fixes" />
|
<MESSAGE value=":bug: Bug fixes" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":bug: Bug fixes" />
|
<MESSAGE value=":bug: Fix hash bug" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix hash bug" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<settings-migrated>true</settings-migrated>
|
<settings-migrated>true</settings-migrated>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="XDebuggerManager">
|
||||||
|
<breakpoint-manager>
|
||||||
|
<breakpoints>
|
||||||
|
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||||
|
<url>file://$USER_HOME$/Applications/GoLang/pkg/mod/git.solsynth.dev/hypernet/nexus@v0.0.0-20241102174036-194d27090415/pkg/nex/sec/perms.go</url>
|
||||||
|
<line>9</line>
|
||||||
|
<option name="timeStamp" value="1" />
|
||||||
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||||
|
<url>file://$USER_HOME$/Applications/GoLang/pkg/mod/git.solsynth.dev/hypernet/nexus@v0.0.0-20241102174036-194d27090415/pkg/nex/sec/perms.go</url>
|
||||||
|
<line>11</line>
|
||||||
|
<option name="timeStamp" value="2" />
|
||||||
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||||
|
<url>file://$USER_HOME$/Applications/GoLang/pkg/mod/git.solsynth.dev/hypernet/nexus@v0.0.0-20241103161217-e1207a8deb28/pkg/nex/sec/perms.go</url>
|
||||||
|
<line>11</line>
|
||||||
|
<option name="timeStamp" value="3" />
|
||||||
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||||
|
<url>file://$USER_HOME$/Applications/GoLang/pkg/mod/git.solsynth.dev/hypernet/nexus@v0.0.0-20241103161217-e1207a8deb28/pkg/nex/sec/perms.go</url>
|
||||||
|
<line>9</line>
|
||||||
|
<option name="timeStamp" value="5" />
|
||||||
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||||
|
<url>file://$USER_HOME$/Applications/GoLang/pkg/mod/git.solsynth.dev/hypernet/nexus@v0.0.0-20241103165336-3e68cea0d783/pkg/nex/sec/perms.go</url>
|
||||||
|
<line>12</line>
|
||||||
|
<option name="timeStamp" value="6" />
|
||||||
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||||
|
<url>file://$USER_HOME$/Applications/GoLang/pkg/mod/git.solsynth.dev/hypernet/nexus@v0.0.0-20241103165336-3e68cea0d783/pkg/nex/sec/perms.go</url>
|
||||||
|
<line>10</line>
|
||||||
|
<option name="timeStamp" value="7" />
|
||||||
|
</line-breakpoint>
|
||||||
|
</breakpoints>
|
||||||
|
</breakpoint-manager>
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
@ -7,11 +7,8 @@ import (
|
|||||||
"gorm.io/datatypes"
|
"gorm.io/datatypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AttachmentDst = int8
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AttachmentDstTemporary = AttachmentDst(iota)
|
AttachmentDstTemporary = 0 // The destination 0 is a reserved config for pre-upload processing
|
||||||
AttachmentDstPermanent
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Attachment struct {
|
type Attachment struct {
|
||||||
@ -27,7 +24,7 @@ type Attachment struct {
|
|||||||
Alternative string `json:"alt"`
|
Alternative string `json:"alt"`
|
||||||
MimeType string `json:"mimetype"`
|
MimeType string `json:"mimetype"`
|
||||||
HashCode string `json:"hash"`
|
HashCode string `json:"hash"`
|
||||||
Destination AttachmentDst `json:"destination"`
|
Destination int `json:"destination"`
|
||||||
RefCount int `json:"ref_count"`
|
RefCount int `json:"ref_count"`
|
||||||
|
|
||||||
FileChunks datatypes.JSONMap `json:"file_chunks"`
|
FileChunks datatypes.JSONMap `json:"file_chunks"`
|
||||||
|
@ -13,6 +13,7 @@ type LocalDestination struct {
|
|||||||
BaseDestination
|
BaseDestination
|
||||||
|
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
AccessBaseURL string `json:"access_baseurl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type S3Destination struct {
|
type S3Destination struct {
|
||||||
|
@ -26,12 +26,7 @@ func openAttachment(c *fiber.Ctx) error {
|
|||||||
return fiber.NewError(fiber.StatusNotFound, "file is in uploading progress, please wait until all chunk uploaded")
|
return fiber.NewError(fiber.StatusNotFound, "file is in uploading progress, please wait until all chunk uploaded")
|
||||||
}
|
}
|
||||||
|
|
||||||
var destMap map[string]any
|
destMap := viper.GetStringMap(fmt.Sprintf("destinations.%d", metadata.Destination))
|
||||||
if metadata.Destination == models.AttachmentDstTemporary {
|
|
||||||
destMap = viper.GetStringMap("destinations.temporary")
|
|
||||||
} else {
|
|
||||||
destMap = viper.GetStringMap("destinations.permanent")
|
|
||||||
}
|
|
||||||
|
|
||||||
var dest models.BaseDestination
|
var dest models.BaseDestination
|
||||||
rawDest, _ := jsoniter.Marshal(destMap)
|
rawDest, _ := jsoniter.Marshal(destMap)
|
||||||
@ -41,10 +36,19 @@ func openAttachment(c *fiber.Ctx) error {
|
|||||||
case models.DestinationTypeLocal:
|
case models.DestinationTypeLocal:
|
||||||
var destConfigured models.LocalDestination
|
var destConfigured models.LocalDestination
|
||||||
_ = jsoniter.Unmarshal(rawDest, &destConfigured)
|
_ = jsoniter.Unmarshal(rawDest, &destConfigured)
|
||||||
|
if len(destConfigured.AccessBaseURL) > 0 && !c.QueryBool("direct", false) {
|
||||||
|
// This will drop all query parameters,
|
||||||
|
// for not it's okay because the openAttachment api won't take any query parameters
|
||||||
|
return c.Redirect(fmt.Sprintf(
|
||||||
|
"%s%s?direct=true",
|
||||||
|
destConfigured.AccessBaseURL,
|
||||||
|
c.Path(),
|
||||||
|
), fiber.StatusMovedPermanently)
|
||||||
|
}
|
||||||
if len(metadata.MimeType) > 0 {
|
if len(metadata.MimeType) > 0 {
|
||||||
c.Set(fiber.HeaderContentType, metadata.MimeType)
|
c.Set(fiber.HeaderContentType, metadata.MimeType)
|
||||||
}
|
}
|
||||||
return c.SendFile(filepath.Join(destConfigured.Path, metadata.Uuid), false)
|
return c.SendFile(filepath.Join(destConfigured.Path, metadata.Uuid))
|
||||||
case models.DestinationTypeS3:
|
case models.DestinationTypeS3:
|
||||||
var destConfigured models.S3Destination
|
var destConfigured models.S3Destination
|
||||||
_ = jsoniter.Unmarshal(rawDest, &destConfigured)
|
_ = jsoniter.Unmarshal(rawDest, &destConfigured)
|
||||||
|
@ -241,7 +241,7 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
|
|
||||||
// Move temporary to permanent
|
// Move temporary to permanent
|
||||||
if !linked {
|
if !linked {
|
||||||
if err := ReUploadFileToPermanent(file); err != nil {
|
if err := ReUploadFileToPermanent(file, 1); err != nil {
|
||||||
return fmt.Errorf("unable to move file to permanet storage: %v", err)
|
return fmt.Errorf("unable to move file to permanet storage: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,12 +94,15 @@ func CheckChunkExistsInTemporary(meta models.Attachment, cid string) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReUploadFileToPermanent(meta models.Attachment) error {
|
func ReUploadFileToPermanent(meta models.Attachment, dst int) error {
|
||||||
|
if dst == models.AttachmentDstTemporary || meta.Destination != dst {
|
||||||
|
return fmt.Errorf("destnation cannot be reversed temporary or the same as the original")
|
||||||
|
}
|
||||||
if meta.Destination != models.AttachmentDstTemporary {
|
if meta.Destination != models.AttachmentDstTemporary {
|
||||||
return fmt.Errorf("attachment isn't in temporary storage, unable to process")
|
return fmt.Errorf("attachment isn't in temporary storage, unable to process")
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.Destination = models.AttachmentDstPermanent
|
meta.Destination = 0
|
||||||
|
|
||||||
destMap := viper.GetStringMap("destinations.permanent")
|
destMap := viper.GetStringMap("destinations.permanent")
|
||||||
|
|
||||||
|
@ -16,13 +16,13 @@ print_routes = false
|
|||||||
[performance]
|
[performance]
|
||||||
file_chunk_size = 26214400
|
file_chunk_size = 26214400
|
||||||
|
|
||||||
[destinations.temporary]
|
[[destinations]]
|
||||||
type = "local"
|
type = "local"
|
||||||
path = "uploads"
|
path = "uploads"
|
||||||
|
[[destinations]]
|
||||||
[destinations.permanent]
|
|
||||||
type = "local"
|
type = "local"
|
||||||
path = "uploads/permanent"
|
path = "uploads/permanent"
|
||||||
|
access_baseurl = "http://localhost:8004"
|
||||||
|
|
||||||
[security]
|
[security]
|
||||||
internal_public_key = "keys/internal_public_key.pem"
|
internal_public_key = "keys/internal_public_key.pem"
|
||||||
|
Loading…
Reference in New Issue
Block a user