Giter VIP home page Giter VIP logo

Comments (8)

greenpau avatar greenpau commented on June 11, 2024

@mahq195 , you are using HTTP. Therefore you need the cookie insecure on.

See: https://authp.github.io/docs/authenticate/auth-cookie

from caddy-security.

thuanpn19 avatar thuanpn19 commented on June 11, 2024

hi @greenpau, following you, now i can see password page in stead of unauthorized. But i still get the above error, also i dont see any password for webadmin user in the logs

from caddy-security.

greenpau avatar greenpau commented on June 11, 2024

following you, now i can see password page in stead of unauthorized. But i still get the above error, also i dont see any password for webadmin user in the logs

@mahq195 , please look in here on how to set your own user: authp/authp.github.io#20 (comment)

from caddy-security.

thuanpn19 avatar thuanpn19 commented on June 11, 2024

Thank a lot, now i can login, but still get some problems:

  1. after logging in, when i reload the page, i want to re-log in again, then get the error
Screenshot 2023-11-23 at 13 31 49
  1. when route to my /app, i get Cannot GET /app. i dont know why

Sorry this is the first time i work with this server and this plugin

Also i provide you my current caddyfile:

{
	order authenticate before respond
	order authorize before basicauth

	security {
		local identity store localdb {
		realm local
		path {$HOME}/.local/caddy/users.json
		user webadmin {
                name webadmin
                email [email protected]
                password "Admin@123" overwrite
                roles authp/admin authp/user
			}
		}

		authentication portal myportal {
			# crypto default token lifetime 3600
			crypto key sign-verify {env.JWT_SHARED_KEY}
			enable identity store localdb
			cookie domain "http://10.20.1.19"
			cookie insecure on
			ui {
				links {
					"My Website" "http://10.20.1.19/app" icon "las la-star"
					"Guests" "http://10.20.1.19/guests" icon "las la-star"
					"Users" "http://10.20.1.19/users" icon "las la-star"
					"Admins" "http://10.20.1.19/admins" icon "las la-star"
					"My Identity" "/auth/whoami" icon "las la-user"
				}
				# password_recovery_enabled yes
			}
			transform user {
				match origin local
				action add role authp/user
				ui link "Portal Settings" /settings icon "las la-cog"
			}
		}

		authorization policy guests_policy {
			set token sources cookie
			validate bearer header
			# disable auth redirect
			set auth url "http://10.20.1.19/auth"
			allow roles authp/admin authp/user
			crypto key verify {env.JWT_SHARED_KEY}
			acl rule {
				comment allow guests only
				match role guest authp/guest
				allow stop log info
			}
			acl rule {
				comment default deny
				match any
				deny log warn
			}
		}

		authorization policy users_policy {
			set token sources cookie
			validate bearer header
			set auth url "http://10.20.1.19/auth"
			allow roles authp/admin authp/user
			crypto key verify {env.JWT_SHARED_KEY}
			acl rule {
				comment allow users
				match role authp/user
				allow stop log info
			}
			acl rule {
				comment default deny
				match any
				deny log warn
			}
		}

		authorization policy admins_policy {
			set token sources cookie
			validate bearer header
			set auth url "http://10.20.1.19/auth"
			allow roles authp/admin authp/user
			crypto key verify {env.JWT_SHARED_KEY}
			acl rule {
				comment allow users
				match role authp/user
				allow stop log info
			}
			acl rule {
				comment default deny
				match any
				deny log warn
			}
		}
	}
}


"http://10.20.1.19" {
	route /auth* {
		authenticate with myportal
	}

	route /app* {
		authorize with users_policy
		reverse_proxy 127.0.0.1:3000
	}

	route {
        redir http://{hostport}/auth 302
	}
}

from caddy-security.

thuanpn19 avatar thuanpn19 commented on June 11, 2024

rightnow i fixed those problems above, the only one i'm facing to is that when i click to "My website", i get like this
Screenshot 2023-11-23 at 16 03 58

I think the problem lying at

route /app/* {
		authorize with users_policy
		reverse_proxy 127.0.0.1:3000
	}

but i dont know to fix it yet :). If you want to see full my caddyfile, check the previous comment.
I am looking forward to get your opion, Mr.@greenpau

from caddy-security.

greenpau avatar greenpau commented on June 11, 2024

but i dont know to fix it yet :). If you want to see full my caddyfile, check the previous comment.

@mahq195 , my guess is that your request reached your reverse proxy (127.0.0.1:3000), but you node.js router is not able to match it.

I would suggest

	route /app* {
		authorize with users_policy
		uri strip_prefix /app
		reverse_proxy 127.0.0.1:3000
	}

from caddy-security.

thuanpn19 avatar thuanpn19 commented on June 11, 2024

hi sir, i already run the plugin, thankyou very much

from caddy-security.

greenpau avatar greenpau commented on June 11, 2024

@mahq195 , resolved?

from caddy-security.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.