mirror of
				https://github.com/steveiliop56/tinyauth.git
				synced 2025-11-04 08:05:42 +00:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
			v4.0.0-bet
			...
			76f2014444
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					76f2014444 | ||
| 
						 | 
					5b7bda3378 | ||
| 
						 | 
					e878516130 | ||
| 
						 | 
					e5f1df03c4 | ||
| 
						 | 
					c77da30d87 | 
							
								
								
									
										2
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							@@ -23,7 +23,7 @@ jobs:
 | 
				
			|||||||
      - name: Install frontend dependencies
 | 
					      - name: Install frontend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          cd frontend
 | 
					          cd frontend
 | 
				
			||||||
          bun install
 | 
					          bun install --frozen-lockfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Set version
 | 
					      - name: Set version
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								.github/workflows/nightly.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/nightly.yml
									
									
									
									
										vendored
									
									
								
							@@ -66,7 +66,7 @@ jobs:
 | 
				
			|||||||
      - name: Install frontend dependencies
 | 
					      - name: Install frontend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          cd frontend
 | 
					          cd frontend
 | 
				
			||||||
          bun install
 | 
					          bun install --frozen-lockfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Install backend dependencies
 | 
					      - name: Install backend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
@@ -112,7 +112,7 @@ jobs:
 | 
				
			|||||||
      - name: Install frontend dependencies
 | 
					      - name: Install frontend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          cd frontend
 | 
					          cd frontend
 | 
				
			||||||
          bun install
 | 
					          bun install --frozen-lockfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Install backend dependencies
 | 
					      - name: Install backend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							@@ -44,7 +44,7 @@ jobs:
 | 
				
			|||||||
      - name: Install frontend dependencies
 | 
					      - name: Install frontend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          cd frontend
 | 
					          cd frontend
 | 
				
			||||||
          bun install
 | 
					          bun install --frozen-lockfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Install backend dependencies
 | 
					      - name: Install backend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
@@ -87,7 +87,7 @@ jobs:
 | 
				
			|||||||
      - name: Install frontend dependencies
 | 
					      - name: Install frontend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          cd frontend
 | 
					          cd frontend
 | 
				
			||||||
          bun install
 | 
					          bun install --frozen-lockfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Install backend dependencies
 | 
					      - name: Install backend dependencies
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -6,7 +6,7 @@ WORKDIR /frontend
 | 
				
			|||||||
COPY ./frontend/package.json ./
 | 
					COPY ./frontend/package.json ./
 | 
				
			||||||
COPY ./frontend/bun.lock ./
 | 
					COPY ./frontend/bun.lock ./
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RUN bun install
 | 
					RUN bun install --frozen-lockfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
COPY ./frontend/public ./public
 | 
					COPY ./frontend/public ./public
 | 
				
			||||||
COPY ./frontend/src ./src
 | 
					COPY ./frontend/src ./src
 | 
				
			||||||
@@ -51,6 +51,10 @@ EXPOSE 3000
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
VOLUME ["/data"]
 | 
					VOLUME ["/data"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["/tinyauth/tinyauth", "healthcheck"]
 | 
					ENV GIN_MODE=release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ENTRYPOINT ["/tinyauth/tinyauth"]
 | 
					ENV PATH=$PATH:/tinyauth
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["tinyauth", "healthcheck"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENTRYPOINT ["tinyauth"]
 | 
				
			||||||
@@ -6,7 +6,7 @@ WORKDIR /frontend
 | 
				
			|||||||
COPY ./frontend/package.json ./
 | 
					COPY ./frontend/package.json ./
 | 
				
			||||||
COPY ./frontend/bun.lock ./
 | 
					COPY ./frontend/bun.lock ./
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RUN bun install
 | 
					RUN bun install --frozen-lockfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
COPY ./frontend/public ./public
 | 
					COPY ./frontend/public ./public
 | 
				
			||||||
COPY ./frontend/src ./src
 | 
					COPY ./frontend/src ./src
 | 
				
			||||||
@@ -51,6 +51,10 @@ EXPOSE 3000
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
VOLUME ["/data"]
 | 
					VOLUME ["/data"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["/tinyauth/tinyauth", "healthcheck"]
 | 
					ENV GIN_MODE=release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ENTRYPOINT ["/tinyauth/tinyauth"]
 | 
					ENV PATH=$PATH:/tinyauth
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["tinyauth", "healthcheck"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENTRYPOINT ["tinyauth"]
 | 
				
			||||||
@@ -8,9 +8,7 @@ const BaseLayout = ({ children }: { children: React.ReactNode }) => {
 | 
				
			|||||||
  const { backgroundImage, title } = useAppContext();
 | 
					  const { backgroundImage, title } = useAppContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  useEffect(() => {
 | 
					  useEffect(() => {
 | 
				
			||||||
    if (title !== "Tinyauth") {
 | 
					    document.title = title;
 | 
				
			||||||
      document.title = title + " - Tinyauth";
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }, [title]);
 | 
					  }, [title]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -172,10 +172,6 @@ func (app *BootstrapApp) Setup() error {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Create engine
 | 
						// Create engine
 | 
				
			||||||
	if config.Version != "development" {
 | 
					 | 
				
			||||||
		gin.SetMode(gin.ReleaseMode)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	engine := gin.New()
 | 
						engine := gin.New()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(app.config.TrustedProxies) > 0 {
 | 
						if len(app.config.TrustedProxies) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,12 @@
 | 
				
			|||||||
package middleware
 | 
					package middleware
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"io/fs"
 | 
						"io/fs"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
	"tinyauth/internal/assets"
 | 
						"tinyauth/internal/assets"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
						"github.com/gin-gonic/gin"
 | 
				
			||||||
@@ -27,14 +29,16 @@ func (m *UIMiddleware) Init() error {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	m.uiFs = ui
 | 
						m.uiFs = ui
 | 
				
			||||||
	m.uiFileServer = http.FileServer(http.FS(ui))
 | 
						m.uiFileServer = http.FileServerFS(ui)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *UIMiddleware) Middleware() gin.HandlerFunc {
 | 
					func (m *UIMiddleware) Middleware() gin.HandlerFunc {
 | 
				
			||||||
	return func(c *gin.Context) {
 | 
						return func(c *gin.Context) {
 | 
				
			||||||
		switch strings.Split(c.Request.URL.Path, "/")[1] {
 | 
							path := strings.TrimPrefix(c.Request.URL.Path, "/")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							switch strings.SplitN(path, "/", 2)[0] {
 | 
				
			||||||
		case "api":
 | 
							case "api":
 | 
				
			||||||
			c.Next()
 | 
								c.Next()
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
@@ -42,12 +46,19 @@ func (m *UIMiddleware) Middleware() gin.HandlerFunc {
 | 
				
			|||||||
			c.Next()
 | 
								c.Next()
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			_, err := fs.Stat(m.uiFs, strings.TrimPrefix(c.Request.URL.Path, "/"))
 | 
								_, err := fs.Stat(m.uiFs, path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Enough for one authentication flow
 | 
				
			||||||
 | 
								maxAge := 15 * time.Minute
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if os.IsNotExist(err) {
 | 
								if os.IsNotExist(err) {
 | 
				
			||||||
				c.Request.URL.Path = "/"
 | 
									c.Request.URL.Path = "/"
 | 
				
			||||||
 | 
								} else if strings.HasPrefix(path, "assets/") {
 | 
				
			||||||
 | 
									// assets are named with a hash and can be cached for a long time
 | 
				
			||||||
 | 
									maxAge = 30 * 24 * time.Hour
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								c.Writer.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", int(maxAge.Seconds())))
 | 
				
			||||||
			m.uiFileServer.ServeHTTP(c.Writer, c.Request)
 | 
								m.uiFileServer.ServeHTTP(c.Writer, c.Request)
 | 
				
			||||||
			c.Abort()
 | 
								c.Abort()
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user