{"id":13794050,"url":"https://github.com/gin-contrib/secure","last_synced_at":"2025-06-13T18:39:36.420Z","repository":{"id":39620513,"uuid":"45836771","full_name":"gin-contrib/secure","owner":"gin-contrib","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-05T02:12:29.000Z","size":74,"stargazers_count":121,"open_issues_count":2,"forks_count":10,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-05-05T03:19:42.210Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gin-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-09T12:30:56.000Z","updated_at":"2024-06-14T02:11:41.677Z","dependencies_parsed_at":"2024-01-13T10:13:46.520Z","dependency_job_id":"962671e4-79e0-47cb-a5ac-1d521a9f89dc","html_url":"https://github.com/gin-contrib/secure","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fsecure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fsecure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fsecure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-contrib%2Fsecure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gin-contrib","download_url":"https://codeload.github.com/gin-contrib/secure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253816745,"owners_count":21968876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T23:00:35.101Z","updated_at":"2025-05-12T20:31:21.541Z","avatar_url":"https://github.com/gin-contrib.png","language":"Go","readme":"# Secure\n\n[![Run Tests](https://github.com/gin-contrib/secure/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/gin-contrib/secure/actions/workflows/go.yml)\n[![codecov](https://codecov.io/gh/gin-contrib/secure/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/secure)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/secure)](https://goreportcard.com/report/github.com/gin-contrib/secure)\n[![GoDoc](https://godoc.org/github.com/gin-contrib/secure?status.svg)](https://godoc.org/github.com/gin-contrib/secure)\n\nSecure middleware for [Gin](https://github.com/gin-gonic/gin/) framework.\n\n## Example\n\nSee the [example1](example/code1/example.go), [example2](example/code2/example.go).\n\nDefaultConfig returns a Configuration with strict security settings\n\n[embedmd]:# (secure.go go /func DefaultConfig/ /^}$/)\n```go\nfunc DefaultConfig() Config {\n\treturn Config{\n\t\tSSLRedirect:           true,\n\t\tIsDevelopment:         false,\n\t\tSTSSeconds:            315360000,\n\t\tSTSIncludeSubdomains:  true,\n\t\tFrameDeny:             true,\n\t\tContentTypeNosniff:    true,\n\t\tBrowserXssFilter:      true,\n\t\tContentSecurityPolicy: \"default-src 'self'\",\n\t\tIENoOpen:              true,\n\t\tSSLProxyHeaders:       map[string]string{\"X-Forwarded-Proto\": \"https\"},\n\t}\n}\n```\n\n[embedmd]:# (example/code1/example.go go)\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/gin-contrib/secure\"\n\t\"github.com/gin-gonic/gin\"\n)\n\nfunc main() {\n\trouter := gin.Default()\n\n\trouter.Use(secure.New(secure.Config{\n\t\tAllowedHosts:          []string{\"example.com\", \"ssl.example.com\"},\n\t\tSSLRedirect:           true,\n\t\tSSLHost:               \"ssl.example.com\",\n\t\tSTSSeconds:            315360000,\n\t\tSTSIncludeSubdomains:  true,\n\t\tFrameDeny:             true,\n\t\tContentTypeNosniff:    true,\n\t\tBrowserXssFilter:      true,\n\t\tContentSecurityPolicy: \"default-src 'self'\",\n\t\tIENoOpen:              true,\n\t\tReferrerPolicy:        \"strict-origin-when-cross-origin\",\n\t\tSSLProxyHeaders:       map[string]string{\"X-Forwarded-Proto\": \"https\"},\n\t}))\n\n\trouter.GET(\"/ping\", func(c *gin.Context) {\n\t\tc.String(200, \"pong\")\n\t})\n\n\t// Listen and Server in 0.0.0.0:8080\n\tif err := router.Run(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n","funding_links":[],"categories":["Middlewares","Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-contrib%2Fsecure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgin-contrib%2Fsecure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-contrib%2Fsecure/lists"}